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

How do you make the head follow your mouse?

Asked by 5 years ago
Edited 5 years ago

I tried it doesn't work, It only moves the head, Not the rotation, Please help My Code:

1local Mouse = game.Players.LocalPlayer:GetMouse()
2local Motor = script.Parent:WaitForChild("Torso"):WaitForChild("Neck")
3 
4while true do
5    wait()
6    Motor.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0) + Mouse.Hit.LookVector
7end

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

I think this should work, this is Code I found some time ago. It was originally written to rotate entire character so I changed it for only head, so I don't know how it will work

01local player = game.Players.LocalPlayer
02 
03local UserInputService = game:GetService("UserInputService")
04 
05local mouse = player:GetMouse()
06local character = player.Character or player.CharacterAdded:wait()
07 
08local Head= character:WaitForChild("Head")
09 
10character:WaitForChild("Humanoid").AutoRotate = false
11 
12 
13local gyro = Instance.new("BodyGyro",Head)
14UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
15gyro .MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
View all 48 lines...
0
It breaks. FixRobloxz 61 — 5y
0
what do you mean by that? GooierApollo664 183 — 5y
0
It does error lol FixRobloxz 61 — 5y
0
what does it say? GooierApollo664 183 — 5y
View all comments (12 more)
0
Workspace.FixRobloxz.LocalScript:6: bad argument #2 to '?' (Vector3 expected, got CFrame) FixRobloxz 61 — 5y
0
I changed it GooierApollo664 183 — 5y
0
It does worse. I need the head to look at the mouse. FixRobloxz 61 — 5y
0
Ok I'm changing everything I think I know how to fix this GooierApollo664 183 — 5y
0
I use motor6d bruh. FixRobloxz 61 — 5y
0
use My script GooierApollo664 183 — 5y
0
That Script? It doesnt work aaaaaaaaaaaaaaa FixRobloxz 61 — 5y
0
What do you mean by that? GooierApollo664 183 — 5y
0
then set desired angle of motor6d that CFrame.Angles( math.atan2( Head.CFrame.Y+mouse.Hit.Y, Head.CFrame.Z-mouse.Hit.Z ) GooierApollo664 183 — 5y
0
I tried it before, I want it to look up and down FixRobloxz 61 — 5y
0
For just up and down, make Y and X axis 0 GooierApollo664 183 — 5y
0
Nah, I already did it. :/ FixRobloxz 61 — 5y
Ad

Answer this question