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

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

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

✓ Accepted answer

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)

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