Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

1 comment

0

please format your code

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.