How do i return a value of the orientation (the angle of where he/she is looking)and position of player?

Sorry for the long title, what could i do to find the orientation and position of the player the local script is running on? Like player.position?

I want to make it so that a part would create in front of the player but i need a script or something to find the position and orientation and then do something like +x to find the position and orientation for the part.

To get a player’s position and orientation on a LocalScript you’d do something along the lines of

local pos = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
local orientation = game.Players.LocalPlayer.Character.HumanoidRootPart.Orientation

To spawn a part in front of the player, you’ll need to create an offset, and use the HumanoidRootPart’s CFrame property.

local offset = Vector3.new(0,0,5)
part.CFrame = HumanoidRootPart.CFrame * CFrame.new(offset)
1 Like

humanoidrootpart.CFrame.LookVector

since they are also asking about “how to return angles”, i’m pretty sure that’s something that has to do with trigonometry which i am not really good at so ill just leave this note here

CFrame accounts for rotation (orientation) which is what he was looking for.

1 Like