Directional Walkspeed

In real life, humans dont move as fast backward as they do forward. This is because of our anatomy and muscle structure.

I want to replicate this. Essentially, For W,A,S,D there will be different Walk Speeds.

FE:
Backward Walkspeed is 8
Forward Walkspeed is 14
Side Walkspeed is 12

Game Example:

(Enter and walk Backwards, Forwards and Side to Side.)

1 Like

In this case I would use Humanoid.MoveDirection which should allow you to find the direction a player is moving in. After this you can determine what direction should correlate to what walkspeed.

Hm, I was thinking of using something like this

	if UserInputService:IsKeyDown(Enum.KeyCode.A) then
		
		KeyTable.Left = true
		
		if KeyTable.Backward == true then return end
		if KeyTable.Forward == true then return end
		
		Humanoid.WalkSpeed = SideSpeed
		
	elseif UserInputService:IsKeyDown(Enum.KeyCode.D) then
		
		KeyTable.Right = true
		
		if KeyTable.Backward == true then return end
		if KeyTable.Forward == true then return end
		
		Humanoid.WalkSpeed = SideSpeed
		
	elseif UserInputService:IsKeyDown(Enum.KeyCode.S) then
		
		KeyTable.Backward = true
		
		Humanoid.WalkSpeed = BackSpeed
		
	elseif UserInputService:IsKeyDown(Enum.KeyCode.W) then
		
		KeyTable.Forward = true

		Humanoid.WalkSpeed = NormalSpeed
		
	else
		KeyTable.Backward = false
		KeyTable.Forward = false
		KeyTable.Left = false
		KeyTable.Right = false
	end

I honestly have no idea how im going to do this

This can also work.

Another thing to keep in mind for the future of your project, if you are going to add/have added an anticheat which includes walk speed detections I would recommend adding enough leniency to prevent false positives because of walk speed changes in regard to this system.

I do have an anticheat, Its well written enough that writing special exceptions is quite easy.

I just dont know how to do this.

I want this directional walkspeed system, But it messes with my sprint mechanic!

You can incorporate this into your sprint mechanic in a few ways.

For one, you could do something slightly different and instead of directly changing walk speed, you could average out the speed based on if the player is sprinting or not along with the direction.

Another way you could do this is by simply disabling sprinting if the player is not moving forward.

Also, What I showed you doesnt work. If you press two keys at the same time it wont ovverite.

HumanoidDirection is the way to go, But ive no idea how to implement it

Its not that, If i try sprinting by pressing shift, Since it sets the walkspeed to the normal speed on W it will simply not allow me to go faster then that

I see. You can change the forward speed number to a different one when sprinting along with updating Humanoid.WalkSpeed, which should solve your issue. (Assuming you’re going for the second option)

If you’re trying for the first, what I meant by averaging the speed was doing some simple equations to determine what the speed should be when setting it in your InputBegan connection as well as in your sprint function.