I am working on an easter game, and when you click on an egg, it is supposed to change a value to true, and then a door is supposed to open. Nothing happens when clicked and no errors. Here is the door's code.
local WaterEggCollected = game.Workspace.Values.WaterEggCollected.Value local Door1 = game.Workspace.Door1 while true do if WaterEggCollected == true then Door1.Transparency = 1 Door1.CanCollide = false end end
Here is the egg code.
function OnClicked (mouse) script.Parent:Destroy() game.Workspace.Values.WaterEggCollected.Value = true end script.Parent.ClickDetector.MouseClick:connect(OnClicked)
First, when you set WaterEggCollected = ....WaterEggCollected.Value
, you set it to the value of the variable at that instant only. It does not update automatically if something changes the variable.
Second, by calling script.Parent:Destroy(), you remove the script's parent, which also destroys the script.
Third, your while loop really needs a wait().
Let me know if you have any more issues.