I have this line of code in my script but when it triggers I go to .2 WalkSpeed and then it increases. The code is on line 18

local loop = true
local debounce = true

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local hum = char:WaitForChild("Humanoid")
        local waittimeFold = plr:WaitForChild("WaitTime")
        local waittime = waittimeFold:WaitForChild("WaitTimeSpd")
        local WalkS = hum.WalkSpeed

        script.Parent.Touched:Connect(function(hit)
            if debounce == false then return end
            debounce = false
            if hit.Parent.Name == plr.Name then
                loop = true
                repeat
                    wait(waittime.Value)
                    hum.WalkSpeed = hum.WalkSpeed + .2
                    waittime.Value = waittime.Value + 1
                until loop == false
            end
            debounce = true
        end)

        script.Parent.TouchEnded:Connect(function(hit)
            if hit.Parent.Name == plr.Name then
                loop = false
            end
        end)
    end)
end)

2 comments

0

So you want a player that touches a part, which Adds '.2' more speed into the players walkspeed?

0

It gradually adds more and more. But the more they do it the longer it takes to gain speed which is what the waittime is for