Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesnt the player head rotate?

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

7 comments

0

also i just tried doing it with server script and nothing happened just as in only local script

0

get rid of the while do loop

0

if your going to need a while loop put it inside CharacterAdded

0

Because Tinkerbell didn't appear.

0

Moving character body parts (not via animations) is extremely difficult task, due to way roblox engine handles humanoids. You will have to find a hacky workaround, not an easy endeavour. Try cloning the head, and hiding the orginal with transparency set to 1. You will have to delete welds (on clone), and make your own. Big job nonetheless.

0

just move the "Neck" Joint, which is the one connecting the head to the torso, rotating it will rotate the head. Try finding it inside the character

0

i tried to change the neck inside properties but nothing happened but i think i will do as you said sleazel

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.