Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make the Character get faster as it moves?

Asked by 7 years ago

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?

2 answers

Log in to vote
0
Answered by
NsNidPL 41
7 years ago
Edited 7 years ago
01local hum = script.Parent:WaitForChild("Humanoid")
02local torso = nil
03 
04--check rig type
05if hum.RigType == "R6" then
06    torso = script.Parent.Torso
07else
08    torso = script.Parent.UpperTorso
09end
10 
11while 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
17end

Put this into StarterCharacterScripts. Works with R6 and R15.

0
Curious over here: Why did you set torso to nil? Is this required? EnlightenedDev 11 — 7y
0
Just in case. It is changed later based on the rig type. NsNidPL 41 — 7y
0
Thank You! Revisedy 23 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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

01Increment = 1 -- It will become this much faster every time
02DelayT = 0.1 -- It will wait this time before it starts the loop again
03defSpeed = 5 -- Starterspeed, this number will change trough the loop
04maxSpeed = 100 -- If you don't want this set it to 99999999999999999999999 or something like that xD
05Speed = defSpeed
06plrWalking = false
07 
08game.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
View all 34 lines...
0
wow NsNidPL 41 — 7y
0
lol User#20388 0 — 7y
0
i need 25 reputation to upvote... what? how do i get reputation since other users havent got reputation and cant upvote... wait... is reputation based on upvoting? NsNidPL 41 — 7y
0
also wouldn't "inf" do the the trick in maxSpeed instead of 99999...? NsNidPL 41 — 7y
View all comments (3 more)
0
Thank you for also answering! Revisedy 23 — 7y
0
If you manually put in inf it doesn't work, so I don't think so xD User#20388 0 — 7y
0
can you make me one that works with the newest version of roblox? i tried this and it did not work. therealdood35 -5 — 6y

Answer this question