Hey there, so I have a body-facing script, which moves the player’s torso and head to where the player is looking based on the camera. But, the positions are based on X and Y Vectors. How would I make this relative to the player and not the X and Y axis?
Here is my script: (dont judge )
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
local UpperTorso = character:WaitForChild("UpperTorso")
local WaistJoint = UpperTorso:WaitForChild("Waist")
local Head = character:WaitForChild("Head")
local NeckJoint = Head:WaitForChild("Neck")
local WaistC0 = CFrame.new(0, 0.2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
local NeckC0 = CFrame.new(0, .8, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
local Camera = workspace.CurrentCamera
game:GetService("RunService").RenderStepped:Connect(function()
local Xangle = math.asin(Camera.CFrame.LookVector.X) * 0.4
local Yangle = math.asin(Camera.CFrame.LookVector.Y) * 0.2
WaistJoint.C0 = WaistC0 * CFrame.fromEulerAnglesXYZ(Yangle, -Xangle, 0)
NeckJoint.C0 = NeckC0 * CFrame.fromEulerAnglesXYZ(Yangle, -Xangle, 0)
end)
ok please help bye