I'm trying to make a BodyPosition value change position to be in front of the player, and above the player.. Problem is when I'm trying to get the part in front of the player, it doesn't work for some reason.. He'res the code I have:
BP.Position = player.Character.HumanoidRootPart.Position + Vector3.new(player.Character.HumanoidRootPart.CFrame.lookVector * 5) + Vector3.new(0,6,0)
What have I done wrong?
Using plus signs in this context will simply add the Vector3 values together, in world space.
To reference a point relative to a CFrame
you can do this:
CFrameHere * Vector3.new(0,3,0)
This line of code will reference a point 3 studs 'above' the CFrame
.
Your code with the new implementation:
BP.Position = player.Character.HumanoidRootPart.Position + player.Character.HumanoidRootPart.CFrame * Vector3.new(0,6,0)
You can turn a CFrame value to a Vector3 value by doing this
local NewCFrame = CFrame.new(0,0,0) * CFrame.angles(0,0,0) local NewVector3 = NewCFrame.p
CFrame.p turns a CFrame to a Vector3