To make the speed increase gradually over time instead of instantly, you can replace the hum.WalkSpeed = 500 with a loop that increments the speed in small steps. Here's the modified code:
Running.OnServerEvent:Connect(function(plr)
game.Workspace:WaitForChild(plr.Name)
local player = game.Workspace:FindFirstChild(plr.Name)
local hum = player.Humanoid
local animPlay = hum:LoadAnimation(Animation)
animPlay:Play()
wait(0.37)
-- Gradual speed increase settings
local startSpeed = hum.WalkSpeed
local targetSpeed = 500
local duration = 1.0 -- Time in seconds to reach target speed
local steps = 20 -- Number of interpolation steps
local stepInterval = duration / steps
local stepSpeedIncrement = (targetSpeed - startSpeed) / steps
for step = 1, steps do
if hum and hum.Parent then -- Check if humanoid still exists
hum.WalkSpeed = startSpeed + (stepSpeedIncrement * step)
wait(stepInterval)
else
break -- Exit if humanoid is removed
end
end
-- Ensure final speed is set accurately
if hum and hum.Parent then
hum.WalkSpeed = targetSpeed
end
end)