Why is my text looping

I was just on roblox studio, I was messing around.
But my text was looping again and again

here is a video >

robloxapp-20201216-1406490.wmv (732.2 KB)

Here is the script >

wait(5)
script.Parent.TextButton.Text = "Oh no! Dont!"

script.Parent.TextButton.MouseButton1Click:Connect(function()
	wait(1)
	script.Parent.TextLabel.Text = "haha no, I wont"
	wait(1)
	script.Parent.TextButton.Text = "I will not let you! I will defeat you!"
	wait(2)
	script.Parent.TextLabel.Text = "Haha, I want a fair fight!"
	wait(2)
	script.Parent.TextButton.Text = ">:)"
	wait(2)
	script.Parent.TextButton.Text = "//click to go\\"
	script.Parent.TextButton.MouseButton1Click:Connect(function()
		if script.Parent.TextButton.Text == "//click to go\\" then
			wait(1)
			game.Workspace.Wall.Transparency = 1
			wait(1)
			game.Workspace.Wall.CanCollide = false
		end
	end)
end)

note : sorry if it was simple problem
I have been develpoing for about 6 months now :confused:

1 Like

You should instead add a cooldown instead of nesting events like that, you can do a thing like this:

local cooldown = false

wait(5)
script.Parent.TextButton.Text = "Oh no! Dont!"

script.Parent.TextButton.MouseButton1Click:Connect(function()
    if not cooldown then
		cooldown = true
		wait(1)
		script.Parent.TextLabel.Text = "haha no, I wont"
		wait(1)
		script.Parent.TextButton.Text = "I will not let you! I will defeat you!"
		wait(2)
		script.Parent.TextLabel.Text = "Haha, I want a fair fight!"
		wait(2)
		script.Parent.TextButton.Text = ">:)"
		wait(2)
		script.Parent.TextButton.Text = "//click to go\\"
		cooldown = "go"
    elseif cooldown == "go" then
		cooldown = true
		wait(1)
		game.Workspace.Wall.Transparency = 1
		wait(1)
		game.Workspace.Wall.CanCollide = false
	end
end)
1 Like