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

I made a script that makes the head looks at mouse, but it doesn't work for r15?

So for my fps, I need to know how to make the character look at the mouse or make the head rotate when the character moves. I found a tutorial and made this script, it works for r6, but not for r15. Can somebody plz help me!

local plr = game.Players.LocalPlayer
local rs = game:GetService('RunService')
local char = plr.Character
repeat wait() until char

local torso = char:FindFirstChild('Torso') or char:FindFirstChild('Head')


repeat wait() until torso

local neck = torso:FindFirstChild('Neck')
local cam = game.Workspace.CurrentCamera

while rs.RenderStepped:Wait() do
	local lv = plr:GetMouse().UnitRay.Direction--mistake im to lazy to edit lel(supposed to be direction for the variable name)
	local adjacent = math.sqrt((lv.X^2)+(lv.Z^2))
	local opp = lv.Y
	local angle = math.atan2(opp, adjacent)
	neck.C0 = CFrame.new(0,1,0)*CFrame.Angles(angle+(math.pi/2),math.pi,0)
end

1 answer

R15 torso's are called "UpperTorso" not "Torso" what you could do, if your game has both avatars enabled check if "UpperTorso" exists or if "Torso" exists, run the code differently for each result

1 comment

0

I putted 'or char:FindFirstChild('Head')' because the neck motor6d is in their for MOTOR6D!

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