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

Why does my script only run once, how can I make the script repeat forever?

I want this script to repeat, tried to add a while true do but it didn't work. Anyone know how I can fix it and make it repeat forever?

script.Parent.ClickDetector.MouseClick:Connect(function(player)
		if player then
			player:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = true
		end
end)

6 comments

0

Normal script or Local script?

0

normal

0

Why would u want to make it repeat forever ?

0

they want it to repeat because if they click, it works, but then if they do it again, it doesnt work. same problem for me.

0

I don't understand why you want it running forever, but you also want it to run when you click something? It can be either or, not both.

0

You can't just make it repeat forever. The script is waiting for a confirmed player to click it then do the following.

1 answer

i think u need to make the frame invisible first sorry if i made something wrong, im not a professional at scripting

local db = true
if db == true then
script.Parent.ClickDetector.MouseClick:Connect(function(player)
        if player then
            player:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = true
            db = false
        end
end)
else
script.Parent.ClickDetector.MouseClick:Connect(function(player)
        if player then
            player:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = false
            db = true
        end
end)
end

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