Roblox Studio 中打印错误的值

我正在使用 Roblox Studio 编写一段代码,根据 LightStaus.Value 的值来更改一些属性。以下是我目前的代码,但它无法正常工作。

while true do
    if script.Parent.Parent.LightStatus.Value == 1 then
        script.Parent.Material = "Neon"
        script.Parent.PointLight.Enabled = true
        script.Parent.SpotLight.Enabled = true
    else
        script.Parent.Material = "SmoothPlastic"
        script.Parent.PointLight.Enabled = false
        script.Parent.SpotLight.Enabled = false
    end
    print(script.Parent.Parent.LightStatus.Value)
    wait(1)
end

我的代码应该打印 LightStatus.Value 的值,但它并没有像下面的图片所示那样做。它打印出 0,即使值为 1。任何帮助都将不胜感激。


打印出 0:

Printing 0


将值设置为 1:

Value set to 1

点赞
用户10794710
用户10794710

我找到了问题所在!

我在本地更改了 LightStatus.Value 的值,因此它没有在客户端更新,这就是为什么它看起来被设置为 true,但实际上是被设置为 false。您可以在此处了解有关客户端/服务器的更多信息。

2020-02-09 23:04:29