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

Stop Repeat on key press?

Asked by
nicros 165
9 years ago

so i am working on a super simple fishing system, and thanks to Ryzox i have a working script that gives gold when i click a brick, then i added in a repeat and stopped you from being able to click it while the repeat is running, but im needing it to stop the repeat when wsad or space is pressed.

but ive got no clue how to do this >>....yes im very noob at Lua, wrote my first line of Lua a few days ago :p soooooo

heres the script i have

Enabled = false

script.Parent.ClickDetector.MouseClick:connect(function(player)
    if Enabled == false then
        Enabled = true
            local Leaderstats = player:findFirstChild("leaderstats")
                if Leaderstats:findFirstChild("Gold") then
                    repeat
                    Leaderstats.Gold.Value = Leaderstats.Gold.Value + 10
                    wait(.5)
                    until Leaderstats.Gold.Value == 100
                    Enabled = false
                end
    end
end)

what line would i add to stop the repeat when w/e key is pressed?

Answer this question