我正在尝试用Lua代码做一个脚本,用来检测我的游戏中的光照水平。我是Lua的新手,所以据我所知,游戏中的光照是一个数字(2,10,5)。
if game:GetService("Lighting").Brightness < 1 then
game.StarterGui.ScreenGui.output.Text = "You are getting cold";
end
我不确定它是否只是没有检测到game:GetService("lighting").Brightness
作为一个数字,或者如果游戏不知道game.StarterGui.ScreenGui.output.Text
是什么。我对此进行了多次测试,每次都做了一些小的修改,但大多数时候我都没有得到错误。使用代码,现在没有错误消息。
发布于 2021-04-06 04:53:39
不要使用game.StarterGui.StarterGui是当玩家加入时,gui被放在玩家的PlayerGui中的东西。玩家看不到StarterGui。而是:
game.Players.PlayerAdded:Connect(function(plr)
if game:GetService("Lighting").Brightness < 1 then
plr.PlayerGui.ScreenGui.output.Text = "You are getting cold";
end
end)
(播放器).PlayerGui是玩家看到的gui。StarterGui不会在游戏更改时自动更新或修改玩家的guis。如果您有更多的问题,请随时提出意见!^-^
Roblox lua文档:https://www.developer.roblox.com/en-us
https://stackoverflow.com/questions/66959566
复制相似问题