you can write a manger not that I’ll understand
I’m not mad at you … I just clearly don’t understand what you’re going for here.
Like, look, the player runs and his speed doubles each time with each run, and then he starts running fast
And if he stops running … it goes back to the starting speed?
Let me get this straight …
They run, the speed doubles. x2
They stop running the speed stays at x2
They run again after stopping, the speed again doubles. Now they are at x4
They stop again the speed stays at x4 …
Is this what you’re looking for?
yes, that’s exactly what I’m looking for
Ok so you don’t need the button to be pressed. You just need them to run.
This is not a sprint code, this is a build speed code … right?
I did this last week. I uses the humanoid.Running
event to build up speed.
Yes, that’s right what I want You’re thinking right
I’ll try to do a basic script.
--Put this in ServerScriptService:
local maxSpeed = 24 --Maximum speed.
local speedIncrement = 0.2 --How much speed to apply every frame.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.Running:Connect(function(speed)
if speed > 0.1 then
if character.Humanoid.WalkSpeed <= (maxSpeed-speedIncrement) then
character.Humanoid.WalkSpeed += walkspeedIncrement
else
character.Humanoid.WalkSpeed = maxSpeed
end
else
humanoid.WalkSpeed = 16
end
end)
end)
end)
Where to write this given Where to write this script?
I told you where. In ServerScriptService.
All thanks to everyone who helped and also helped, good luck to everyone!
Ya, I don’t see how this is solved … It has errors but I like the approach.
So, I think this is more what you’re going for here.
When you start running the speed builds. if you stop it starts over.
-- non-local script in ServerScriptService
local maxSpeed = 32 -- Maximum speed.
local speedIncrement = 0.2 -- How much speed to apply when running.
local defaultWalkSpeed = 16 -- Default walking speed.
local rs = game:GetService("RunService")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
local isRunning = false
local function updateSpeed()
if isRunning and humanoid.WalkSpeed < maxSpeed then
humanoid.WalkSpeed = math.min(humanoid.WalkSpeed + speedIncrement, maxSpeed)
end
end
local function resetSpeed()
isRunning = false
humanoid.WalkSpeed = defaultWalkSpeed
end
humanoid.Running:Connect(function(speed)
isRunning = speed > 0.1
end)
rs.Stepped:Connect(function()
if isRunning then updateSpeed()
else resetSpeed()
end
end)
end)
end)
Sorry so many edits … I seem to be sloppy today.
Nice work @abs
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.