I'm making a floating doll that floats above your shoulder, But I don't know how to make it face the direction the player's facing. Could someone help me out?
Here's the script that I made to make the doll stay above the player's shoulder:
local player = game.Players.LocalPlayer while wait(0.1) do local character = player.Character if character ~= nil then script.Parent.Doll.Body.BodyPosition.Position = character:FindFirstChild("Right Arm").Position + Vector3.new(0,3,0) end end
The easiest way to do this is to copy the rotation matrix of the character's torso's CFrame into the doll:
local cframe = character.Torso.CFrame - character.Torso.CFrame.p local doll = script.Parent.Doll.Body doll.CFrame = CFrame.new(doll.CFrame.p)*cframe
Now say it doesn't look quite right and you want to offset the CFrame. You can do this quite easily by multiplying the CFrame by the desired angles.
Example:
doll.CFrame = doll.CFrame*CFrame.Angles(math.rad(90), math.rad(-15), 0)
local player = game.Players.LocalPlayer while wait(0.1) do local character = player.Character if character then local cframe = character.Torso.CFrame - character.Torso.CFrame.p local doll = script.Parent.Doll.Body doll.CFrame = CFrame.new(doll.CFrame.p)*cframe doll.CFrame = doll.CFrame*CFrame.Angles(math.rad(90), math.rad(-15), 0) -- The line above is optional, depending if you want rotation doll.BodyPosition.Position = character["Right Arm"].Position + Vector3.new(0, 3, 0) end end