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

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

Asked by
Tan0ak 28
4 years ago

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

Log in to vote
1
Answered by
sngnn 274 Moderation Voter
4 years ago
Edited 4 years ago

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
0
Thank you Tan0ak 28 — 4y
0
But one thing, when I do it my player just teleports. Is there any way to make it a niice smooth transition Tan0ak 28 — 4y
0
Tweening exists, and you can also use BodyPosition. sngnn 274 — 4y
0
could you tell me how i could use that in this case Tan0ak 28 — 4y
View all comments (2 more)
Ad

Answer this question