Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a max speed so that if the player exceeds the speed limit it doesn't go above it?

Asked by 4 years ago
Edited 4 years ago

local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local wins = player.leaderstats.Wins local value = 10
wins.Changed:Connect(function() humanoid.WalkSpeed = humanoid.WalkSpeed + value end)

This is the code that I have written for the speed Increase and I want to add a speed limit. Please tell

0
please format your code User#34187 8 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Try this

local player = game.Players.LocalPlayer 
local character = player.Character or player.CharacterAdded:Wait() 
local humanoid = character:WaitForChild("Humanoid") 
local wins = player.leaderstats.Wins 
local value = 10
local limit = 100

wins:GetPropertyChangedSignal('Value'):Connect(function() 
    if value < limit then
        humanoid.WalkSpeed = humanoid.WalkSpeed + value 
    else
        humanoid.WalkSpeed = 16 + limit -- Fix the WalkSpeed at the limit.
    end
end)

Hope this help, to more questions put bellow in commentaries.

Ad

Answer this question