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

Hey, I posted a new edit to the question you asked, that should be the final edit, everything should work, remember to accept the answer if it does!

0

walkspeed is a number value