Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesnt the player head rotate?

Asked by 4 years ago

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

0
also i just tried doing it with server script and nothing happened just as in only local script Gameplayer365247v2 1055 — 4y
0
get rid of the while do loop DragonSkyye 517 — 4y
0
if your going to need a while loop put it inside CharacterAdded DragonSkyye 517 — 4y
0
Because Tinkerbell didn't appear. NIMI5Q -2 — 4y
View all comments (3 more)
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. sleazel 1287 — 4y
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 starmaq 1290 — 4y
0
i tried to change the neck inside properties but nothing happened but i think i will do as you said sleazel Gameplayer365247v2 1055 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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
Ad

Answer this question