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

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by
Arkrei 389 Moderation Voter
4 years ago
Edited 4 years ago

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

0
I putted 'or char:FindFirstChild('Head')' because the neck motor6d is in their for MOTOR6D! Cooltech90 -3 — 4y
Ad

Answer this question