Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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)
0
Normal script or Local script? laurenbtd5 379 — 4y
0
normal AnimatedSL -3 — 4y
0
Why would u want to make it repeat forever ? Nguyenlegiahung 1091 — 4y
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. lqveries 17 — 4y
View all comments (2 more)
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. JigglyWiggles 15 — 4y
0
You can't just make it repeat forever. The script is waiting for a confirmed player to click it then do the following. nekosiwifi 398 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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
Ad

Answer this question