0

# How do you change player walkspeed based on leaderstat?

For example if a players leaderstat equals to 10, the player will have 10 walkspeed.

0
Edited 11 days ago

localscript

while wait(0.1) do
end

0
Edited 10 days ago

Use the event :GetPropertyChangedSignal() in the walkspeed leaderstat and it will fire if a certain property changes.

For example, we put "Name" between the parenthesis. If the Name of the walkspeed leaderstats changes, this will fire. For this one, we must use "Value".

Also don't forget to do the same thing to the humanoid walkspeed.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player) -- this event will fire when a player joins
local Leaderstats = Instance.new("Folder", Player) -- creates the leaderstats inside the Player

WalkSpeed.Name = "Speed"

Player.CharacterAdded:Connect(function(Character) -- this event will fire when the player's character has loaded/respawned
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
WalkSpeed.Value = Humanoid.WalkSpeed

WalkSpeed:GetPropertyChangedSignal("Value"):Connect(function() -- this event will fire if the Value of WalkSpeed changes
Humanoid.WalkSpeed = WalkSpeed.Value
end)

Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function() -- this event will fire if the speed of player changes
WalkSpeed.Value = Humanoid.WalkSpeed
end)
end)
end)