Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my Roblox studio crashes when i click the part?

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)

1 answer

✓ Accepted answer

##Problem:

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)

##Resources: Stacks

Similar Question

Ask me if you have more questions

This discussion is preserved as it was. New answers, comments, and votes are closed.