#Running system

1 messages · Page 1 of 1 (latest)

unique cloak
#

So I have this code that increases speed instantly when holding E (From client using remoteEvent)
Instead of instantly, how do I mak it increase speed over time?

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)
hum.WalkSpeed = 500
end)

#

See how hum.WalkSpeed = 500 instantly,

#

Instead I want it to incrementally increase to a very high numberrr

cloud crescent
#

You could try using smoothdamp to achieve this effect

#

Or if you want it to be completely linear, you could create a Tween whose EasingStyle is linear.

broken burrow
#

"running system".
the system:

cloud crescent
#

You also sort of repeat yourself on the second line
game.Workspace:WaitForChild(plr.Name)
local player = game.Workspace:FindFirstChild(plr.Name)

Just make it one variable, and name it as a character of a player, not a player, and you shouldn't really check the workspace for a model named the same as the player

pure fjord
keen portal
#

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)

#

@unique cloak

unique cloak
#

Thx

unique cloak
broken burrow
keen portal
unique cloak
#

Uh ye

unique cloak
unique cloak
keen portal
#

If you want

unique cloak
#

What for?

#

@keen portal Also this works, can i use this instead?

#

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.2)
for myCounter = 1, 25, 1 do
    hum.WalkSpeed = hum.WalkSpeed + 50
end

end)

keen portal
keen portal
#

Do you understand

unique cloak
#

also

#

i dont want 500

broken burrow
keen portal
unique cloak
broken burrow
# unique cloak Wait so is there any way I can make it efficient without doing what you did

at your stage you should really just ignore efficiency, optimization, and performance outright, and focus on simply getting things to work properly. what they're saying is your math is wrong for starts (doesn't end on 500), and second it will instantly jump to max speed when you clearly intended a smooth increase over time. I suggest using tweenservice for that, you can look up tweenservice in the docs http://wiki.roblox.com

Learn with documentation and resources for all creators.

unique cloak
#

k thx

keen portal
rose hingeBOT
#

studio** You are now Level 9! **studio

unique cloak
rose hingeBOT
#

studio** You are now Level 6! **studio

unique cloak
#

Isn't this place for unconditional help

#

@keen portal Also have you made any games

keen portal
keen portal
unique cloak
#

Because

#

if you are good at scripting

#

you can make robux

#

@keen portal

keen portal