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

How to make a part face the player's look direction ?

I've made a script that create a cylinder in front of you. It's supposed to face the same direction as the player's HumanoidRootPart but it doesnt. Here is the script :

local circle = Instance.new("Part", game.Workspace)
circle.Anchored = true
circle.CanCollide = false
circle.Transparency = 0.5
circle.Shape = "Cylinder"
circle.Size = Vector3.new(0.1,5,5)
circle.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position + player.Character.HumanoidRootPart.CFrame.lookVector * 5, player.Character.HumanoidRootPart.CFrame.lookVector)

2 comments

0

CFrame.lookVector

0

Can't you see that i already tried this ?

1 answer

✓ Accepted answer

You're currently using the CFrame.new(Position, LookAt) constructor. Try this instead:

CFrame.new(player.Character.HumanoidRootPart.Position + player.Character.HumanoidRootPart.CFrame.lookVector * 5) * CFrame.new(Vector3.new(0,0,0), player.Character.HumanoidRoot.CFrame.lookVector)

Alternatively,

player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5)

May also work.

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