generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How do you get the players head to follow your mouse?

Previous Thread :: Next Thread 
Haschwalth is not online. Haschwalth
Joined: 30 Sep 2009
Total Posts: 24661
06 Jan 2015 01:54 PM
I am currently working on a localscript that has the player rotate in the direction of the mouse, but I am unable to have the player's head increase/decrease its attitude.I have been trying to figure this out.

I tried something along the lines of:

local direction
local Mouse = player:GetMouse() -- Player is already defined

head = player.Character.Head.
direction = (Mouse.Hit.p-head.Position).unit
head.CFrame = CFrame.new(head.Position) * CFrameAngles(math.asin(direction.Y),0,0)

It angles the entire body to follow the pitch that is supposed to only be working for the head, and cancels the other part of the script that I have to rotates the players body along the x and z axis.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
06 Jan 2015 02:32 PM
local player = game.Players.LocalPlayer
local character, mouse = (player.Character or player.CharacterAdded:wait()), player:GetMouse()
neck = character.Torso.Neck
wait(3)
mouse.Move:connect(function()
neck.C1 = (CFrame.new(character.Head.Position, mouse.Hit.p)):toObjectSpace(character.Torso.CFrame * neck.C0);
end)
Report Abuse
Haschwalth is not online. Haschwalth
Joined: 30 Sep 2009
Total Posts: 24661
06 Jan 2015 03:13 PM
For the most part it works 128GB, but the head can go off of the neck.

Thank you for your help
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
06 Jan 2015 03:18 PM
I can't help you anymore than I already have, sorry it doesn't work correctly

Maybe you can look at some models of guns that do that,
Report Abuse
Haschwalth is not online. Haschwalth
Joined: 30 Sep 2009
Total Posts: 24661
06 Jan 2015 03:49 PM
It's fine, I wasn't expecting you too xD

I was just saying I really appreciated your help :3
Report Abuse
Haschwalth is not online. Haschwalth
Joined: 30 Sep 2009
Total Posts: 24661
06 Jan 2015 03:52 PM
128GB

I think you have a voodoo script on me.

When I tried your code, my necked cracked and now I can't turn my head to the right o_O

Now I'm sitting here in pain.

Lawsuit incoming. xD
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image