I have an NPC/player that's constantly moving and I want to spawn something (a brick) in front of their current location. By in front, I mean the direction that the NPC/player is facing.
Yes, I get the position of the player and do a +10 or whatever distance I want to put it in front of the NPC. But how can I tell whether to add the +10 on the X or the Z axis of the vector3/cframe? How do I know the direction that the NPC is facing?
Hi Ribasu,
brick.CFrame = torso.CFrame * CFrame.new(0, 0, -10);
Thanks,
Best regards,
~~ KingLoneCat
You can use lookVector property of CFrame
local npc = workspace.NPC local torso = npc.Torso local part = Instance.new"Part" part.Parent = workspace part.CFrame = torso.CFrame + torso.CFrame.lookVector * 2