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

[CFrame] Moving the characters head to your mouse.Hit??

Asked by 10 years ago

10:05:24.356 - Players.Player.PlayerGui.LocalScript:12: bad argument #3 to 'Angles' (number expected, got userdata)

local plr=game.Players.LocalPlayer
local mouse=plr:GetMouse()

plr.Character.Torso.Neck.C0=CFrame.new(0,1.5,0)*CFrame.Angles(0,0,mouse.Hit)

1 answer

Log in to vote
0
Answered by 10 years ago

EDIT: I realized I was completely wrong. Use mouse.Hit.Z

mouse.Hit returns a CFrame value.

local plr = game.Players.LocalPlayer
local m = plr:GetMouse()

m.Button1Down:connect(function(mouse)
    print(m.Hit)
end)

-> 0.0844552889, 0, -0.412481308, -0.999974728, 0.00373247126, -0.0060590161, -0, 0.851417065, 0.524489343, 0.00711639086, 0.524476111, -0.851395488

I think what you're looking for is mouse.Hit.p which returns the position of a part

local plr = game.Players.LocalPlayer
local m = plr:GetMouse()

m.Button1Down:connect(function(mouse)
    print(m.Hit.p.Z)
end)

-> 0,0,0

Use mouse.Hit.p.Z to get the Z value, so your new code would be:

local plr=game.Players.LocalPlayer
local mouse=plr:GetMouse()

plr.Character.Torso.Neck.C0=CFrame.new(0,1.5,0)*CFrame.Angles(0,0,mouse.Hit.p.Z)
Ad

Answer this question