Ad
Log in to vote
-1

What is wrong with this script?

Asked by 7 years ago

Hi, Is just that I'm making this sprint but something is wrong with the debounce and I don't know how to fix it, everything else is okey since the Output shows no errors.

The idea is for the "Repeat" loop to stop subtracting the value 1 to SoulPoints if the Debounce SF becomes true or if SoulPoints reaches 0, It stops once the value is 0 but not when SF equals true. This might be a total beginner error but please help me.

Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
ST = false
SF = false

function Sprint(key)
    Key = key:lower()

    if Key == Skills["Sprint"].HotKey.Text and ST == false and SF == false and SoulPoints.Value >= 1 then
        ST = true

        Hum.WalkSpeed = 50

        repeat
        SoulPoints.Value = SoulPoints.Value - 1
        wait()
        until
        SF == true or SoulPoints.Value == 0
    end
end

function SprintStop(key)
    Key = key:lower()

    if Key == Skills["Sprint"].HotKey.Text and ST == true and SF == false then
        ST = false
        SF = true

        Hum.WalkSpeed = 16
    end
    SF = false
end

Mouse.KeyDown:connect(Sprint)
Mouse.KeyUp:connect(SprintStop)

2 answers

Log in to vote
3
Answered by
MrNicNac 855 Moderation Voter
7 years ago

On lines 27-31. Notice how you set SF to true, but not even within a frame, you're setting it back to false. The repeat loop has almost no time to catch the change. Instead of having SF=false on line 31, put it below line 18.

0
Yes, Thank you so much, it worked. Slazerick 55 — 7y
Ad
Log in to vote
-7
Answered by 7 years ago

you forgot ~~~~~~~~~~~~~~~~~ end ~~~~~~~~~~~~~~~~~ i think

0
i mean "end" cristinon 0 — 7y
0
No... That's just plain... I mean no, if I where missing an end, the output would have told me. Slazerick 55 — 7y

Answer this question