I tried making an egg game when you click the egg it changes a value to true, which opens a door. But it doesn’t work with no errors. I tried searching it up, but no luck.
Code of the door.
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
Code of the egg.
function OnClicked (mouse)
script.Parent:Destroy()
game.Workspace.Values.WaterEggCollected.Value = true
end
script.Parent.ClickDetector.MouseClick:connect(OnClicked)
EDIT: It actually showed the error" [17:46:09.222 - Script timeout: exhausted allowed execution time]"
local WaterEggCollected = game.Workspace.Values.WaterEggCollected.Value
local Door1 = game.Workspace.Door1
while true do
wait()
if WaterEggCollected == true then
Door1.Transparency = 1
Door1.CanCollide = false
end
end
If what starmaq said doesn’t work, then try making all the scripts server scripts. Cause the script that sets the value could be a local script and it might not replicate.
I did use server scripts, I know the egg click script works, because it changes the value of the boolvalue “WaterEggCollected”, so I don’t know why it is not working in the door script.
local WaterEggCollected = game.Workspace.Values.WaterEggCollected
local Door1 = game.Workspace.Door1
WaterEggCollected.Changed:Connect(function()
if WaterEggCollected.Value then
Door1.Transparency = 1
Door1.CanCollide = false
end
end)