local hum = script.Parent.Humanoid
hum.Running:connect(function(spd)
if spd > 0 then
-- started running
while hum.MoveDirection.magnitude > 0 do
wait()
hum.WalkSpeed = math.clamp(hum.WalkSpeed + 0.5, 0, 45)
end
else
-- stopped running
hum.WalkSpeed = 16
end
end)
i'd personally recommend just using the running event because it also fires when running stops so you can reset speed
also I clamped the value at a max of 45 but you can use whatever method to change the player's speed |