In the game I am creating, a part of it will be to find objects that help speed (Which I was able to script) up the player, while over time their speed decrease (Which I need help with)
I am very new to scripting and can't seem to find any scripting problems that involve decay of speed from touching a block.
What I want to achieve is to create a script that allows for the Walkspeed to decrease by 1 every 3 seconds, until it reaches 0, I have tried the script below, and although it slows me down, it does it too quickly.
TLDR: I need a script that when touched once, reduces the players speed by 1 every 3 seconds. The one I currently have (below) registers all parts of a player that hit the block, and slows them down almost instantly.
script.Parent.Touched:Connect(function(hit)
repeat
hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed - 1
wait (3)
until hit.Parent.Humanoid.WalkSpeed == 0
end)

1 comment
This makes so much more sense, thank you! I kept on seeing debounce in the scripts I was looking at and passed it off as a variable instead of what its actual function was, TY!!!!!!