so i want to make a part that if you click it a textlabel in another part visible but when i click it my roblox studio crashes
this is my script:
local Text = game.Workspace.CLICKTHIS.SurfaceGui.TextLabel.Visible function OnClicked() if OnClicked() then wait(3) Text = true end end script.Parent.ClickDetector.MouseClick:Connect(OnClicked)
The error is caused by a stack overflow.
On your function onClicked, a recursion is happening which never ends or repeat.
What is a stack overflow?
A stack overflow is a problem faced when using stacks. It occurs when the stack grows larger than the area it has been allocated.
Solution:
Just remove the onClicked() function on line 4, and this should work!
local Text = game.Workspace.CLICKTHIS.SurfaceGui.TextLabel.Visible function OnClicked() wait(1) -- the amount of secs you want this to run! print ("hello") Text = true end script.Parent.ClickDetector.MouseClick:Connect(OnClicked)
Ask me if you have more questions