Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can i make a move in the direction they are facing?

So I am adding a rolling feature to my game. Ik how to do the animation part but do not not how to make the player move in the direction they are facing. help

Here is my animation script:

local UIS = game:GetService('UserInputService')
local Anim = script.Parent:WaitForChild('RollAnim')

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.R then
		local Animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Anim)
		Animation:Play()
	end
end)

1 answer

✓ Accepted answer

What you're looking for is called LookVector.

The forward-direction component of the CFrame’s orientation. Equivalent to: Vector3.new(-r02, -r12, -r22)

-developer site

You could make the player move by doing:

player.CFrame += player.CFrame.LookVector*studs

6 comments

0

Thank you

0

But one thing, when I do it my player just teleports. Is there any way to make it a niice smooth transition

0

Tweening exists, and you can also use BodyPosition.

0

could you tell me how i could use that in this case

0

I'll send some links:

This discussion is preserved as it was. New answers, comments, and votes are closed.