How to make a script that makes the value the same as the players walkspeed

so i have this script that makes the value the same as the players walkspeed but it dosent really work how should i fix this?

while true do
	script.Parent.WalkspeedValue.Value = game.Players.LocalPlayer.Character.Humanoid.WalkSpeed 
end

Is it in a server script or a local script?

it is a localscript, but i dont know if it works in a script

Put a wait()

while true do
	script.Parent.WalkspeedValue.Value = game.Players.LocalPlayer.Character.Humanoid.WalkSpeed 
    wait()
end

This will detect when the walk speed changes instead of constantly checking and updating, which is much better performance wise

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

hum:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
    script.Parent.WalkspeedValue.Value = hum.WalkSpeed
end)

well it works but now it lags abit for some reason

Use the script that I put because it won’t lag at all

1 Like

ah it dosen’t lag thank you !!