Auto running script

How do i make the player automaticly run? So the player always runs. Without pressing any buttons.
It needs to be relative to the camera.

4 Likes

Im not entirely certain what you mean by this. If you mean that a character is always at a faster speed then the default one you would put a script in ServerScriptService which looks like this:

--PlayerAdded Function runs when the player is added (Finds the player)

game.Players.PlayerAdded:Connect(function(Player)
	
	
	--When the players character is added do the following:
	--Since the character is always in the game this script doesnt need a loop.
	Player.CharacterAdded:Connect(function(Character)
	--Change the characters walkspeed to a number
	Character.Humanoid.WalkSpeed = 20 --It doesnt have to be 20 its your choice.
	end)
end)
1 Like

I know how to change the speed. I want the player to always walk/run. In this case, run.

You’re on about animations im guessing…? You could replace the old walk animation with a running animation and set the walkspeed aswell as mentioned by Alexander

1 Like

I tried that. But i am always changing the direction of the camera so it didn’t work. Do you know how to get around that issue?

Just to add to intervising’s post.


https://gyazo.com/f08361320a499e711b8ef82bb0e65809

The second parameter is to deal with camera relativity, messing with it could help

I used that with a while loop. The player just spinned around, How should i use it correctly?

Try using Humanoid:MoveTo() instead as you simply only supply a position not a direction:

As i said. I cant have a single position. I need it to be moving straight forward all the time. The player turn and them the movement turns with it.

if humanoid:Move() is not working then you could again use MoveTo() and set a position that’s thousands of studs infront of the player if your player constantly needs to move fordward.

And when i turn. The player will move towards that same position and not turn.

Wait, you said it needs to be relative to the camera… in that case, you will want to either force shift lock or first person by either going into startplayer and enabling firstpersonlock or by following this article:

From there, you shouldn’t have a problem with humanoid:Move()

I have already made the camera part. Shift lock can’t handle rotation. I have made it 100% fixed. But if i use :Move() then the player starts to spin.

Can you send a video or a place file that can help with understanding this problem because im a bit lost at the moment. Apologies.

I will send it in dms. Because i don’t want it to be stolen.

1 Like

Their is too little information to really help.

We need an example of what exactly you’re trying to achieve, what you have tried already (code would be ideal) or even a video of what you want to achieve.

There are lots of capable developers here to help you, but we’re not mind-readers.

1 Like
game:GetService("RunService").RenderStepped:Connect(function()
    Humanoid:Move(Vector3.new(0,0,-1), true)
end)

in a local script, should make the character move forward (relative to camera)
:Move() function needs to be called in a constant renderstep loop to update it every time, the direction in the first argument is Vector3.new(0,0,-1) which is just a forward vector, the second argument (true) means it’s relative to the camera, so no matter where you look towards, the character will move forward relative to your camera.

9 Likes

But how would i control the speed for this, the speed is super slow unless the player manually presses w

generally you woould control it with humanoid.WalkSpeed, but pressing W speeding it up is some weird behavior