Hello! I’m currently trying to make a speed type game, and i need to add a max player speed. I’m stuck on this part and i’m not sure how i should make it. Any help would be very apprechiated!
The system
Right now i am just using a simple script that keeps on adding more WalkSpeed each time a “Steps” value increases. I am trying to make a cap for this, say i made the speed cap like 184. Then the player would stop gaining more speed at 184 WalkSpeed. If you need any more details please just message me!
Doesn’t this just keep switching between the min and max value?
I would like the player to keep the gained speed and then just make it cap out at a specific amount.
If you do not want the players to go across 184 WalkSpeed, this is pretty simple.
local limit = 184
local plr = game.Players.LocalPlayer
local humanoid = plr:WaitForChild("Humanoid")
humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
if humanoid.WalkSpeed > limit then
humanoid.WalkSpeed = limit
elseif humanoid.WalkSpeed <= limit then
humanoid.WalkSpeed += 1
end
end)
(stumbled back on this post & i edited the code to optimize it slightly)