✓ Accepted answer
So basically the GUI's don't load in as fast as the player does.
Easy fix.
We use the WaitForChild() Method to wait for a child. WaitForChild() "yields" (waits) the script until it has found a child. Unlike FindFirstChild(), it returns a true or false boolean, making it effective for if statement procedures.
WaitForChild's purpose is to not let parents of the children load too fast making errors.
There is also another problem. You are referencing the GUI under the player itself. There is about two solutions to fix that and I'll show it.
Your script fixed by WaitForChild() and the GUI thing would be:
script.Parent.MouseButton1Click:Connect(function(player)
script.Parent.Parent:WaitForChild("TextLabel").Text = "Have a Nice Night!"
wait(1)
game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").CandyFrame.Visible = false
end)
You can ask clarification any time.
4 comments
I just realised its the 30th i have been working on this since the 10th this month
You know what? im going to keep working on this and release the update next halloween
AND i got the houses done like 4 days ago
all GUI elements are descendants of player.playerGui, and not the player itself