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

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?

1
Well i'm not sure what you're trying to do here and by the looks of it you are already stopping the loop once the gold = 100 so what are you trying to do with keys? Ryzox 220 — 9y
1
Look up KeyDown events and stuff, posted above bby RRCTrooper. Create a variable that tells the repeat loop whether or not it can run. repeat if VALUE then STUFF end until CONDITION Validark 1580 — 9y
0
hehe thanks guys, and yex ryzox i had the gold = 100 as a place holder so it wouldn't be an endless loop :P nicros 165 — 9y

Answer this question