im not sure if this needs to be a server script fired by a local script or something but i wanted to try make a head rotation script that rotates to where ever the mouse is pointed and here is the script local script:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() while wait() do player.CharacterAdded:Connect(function(character) character.Head.Orientation = Vector3.new(mouse.hit.p) end) end
after this failed i tried to rotate my head manually using the rotate tool and it instantly killed my character, how would i make this work without dying
mouse.hit.p is a position in 3D space. Orientation is a vector3 object, but it store degrees, 0, 90, 180..., so you cannot assign a position to a orientation.
you have to use CFrame(currentPosition, mousePointer) function to rotate your character, my code is like this
if character then -- I don't want to use mouse Y because I don't want character look at sky local direction = Vector3.new(mouse.Hit.p.X, character.HumanoidRootPart.Position.Y, mouse.Hit.p.Z) -- the if then below is for R15 and R6, if game is using R15, no need for second part if character:FindFirstChild("HumanoidRootPart") then character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.Position, direction) else character.Torso.CFrame = CFrame.new(character.Torso.Position, direction) end end