What would I put in a script to make when the character moves it picks up speed? Would I use a loop to add to the players speed by increments?
01 | local hum = script.Parent:WaitForChild( "Humanoid" ) |
02 | local torso = nil |
03 |
04 | --check rig type |
05 | if hum.RigType = = "R6" then |
06 | torso = script.Parent.Torso |
07 | else |
08 | torso = script.Parent.UpperTorso |
09 | end |
10 |
11 | while wait() do --put a number in the () if you want to slow down speed incerasing |
12 | if torso.Velocity.Magnitude > 1 then |
13 | hum.WalkSpeed = hum.WalkSpeed + 0.1 --this is how the walkspeed incerases |
14 | else |
15 | hum.WalkSpeed = 16 --default walkspeed |
16 | end |
17 | end |
Put this into StarterCharacterScripts. Works with R6 and R15.
You should indeed use loops and use increments, It isn't done completely in a loop because it would add to the speed when the player isn't moving, script is below, the explenation is too, if you need some more explanation, feel free to ask (btw mark this as answered please xD)
Script needs to be in workspace
01 | Increment = 1 -- It will become this much faster every time |
02 | DelayT = 0.1 -- It will wait this time before it starts the loop again |
03 | defSpeed = 5 -- Starterspeed, this number will change trough the loop |
04 | maxSpeed = 100 -- If you don't want this set it to 99999999999999999999999 or something like that xD |
05 | Speed = defSpeed |
06 | plrWalking = false |
07 |
08 | game.Players.PlayerAdded:connect( function (player) |
09 | player.CharacterAdded:connect( function (char) |
10 | player.Character.Humanoid.Running:connect( function (speed) |
11 | if speed > 0 then -- player isn't standing still |
12 | plrWalking = true |
13 | else |
14 | plrWalking = false |
15 | end |