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

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

Asked by 6 years ago
Edited 6 years ago

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)
0
CFrame.lookVector DeceptiveCaster 3761 — 6y
0
Can't you see that i already tried this ? NotZuraax 68 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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.

Ad

Answer this question