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

How do you make "lol"only prints once, not like over 100 times?

Asked by 7 years ago
Edited 7 years ago

Why is "lol" printed a lot more than 1 time like over 100 times, and how do you make it so it only prints once? It has to stay in the loop so it can check for the button.

while wait(0.03125) do
    if player.PlayerGui.ScreenGui:FindFirstChild("JumpPowerTextButton") then
        player.PlayerGui.ScreenGui.JumpPowerTextButton.MouseButton1Down:connect(function()
    print("lol")
end)
    end
end

1 answer

Log in to vote
0
Answered by 7 years ago

You're using a while wait loop. Instead use a while true loop.

while player.PlayerGui.ScreenGui:FindFirstChild("JumpPowerTextButton") do
    wait(.03125)
    player.PlayerGui.ScreenGui.JumpPowerTextButton.MouseButton1Down:connect(function()
        print("lol")
    end)
end
0
While wait runs the script every .03125 seconds whether or not the if then statement returns true. Ethan_Waike 156 — 7y
Ad

Answer this question