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

?So basically I'm trying to do a local script that rotates the hands and head to the mouse.

Hi, programmers!

So basically I'm trying to do a local script that rotates the hands and head to the mouse, but I got stuck here ...

https://ctrlv.tv/eIY7 <= My problem

My scripts:

local player = game.Players.LocalPlayer --local script in starterGui
local mouse = player:GetMouse()
game:GetService("RunService").RenderStepped:Connect(function() 
    mouse.TargetFilter = workspace 
    player.Character.Torso.Neck.C1 = CFrame.new() 
    player.Character.Torso.Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin((mouse.Hit.p - mouse.Origin.p).unit.y), 0, 0)


 
player.Character.Torso:WaitForChild("Left Shoulder").C1 = CFrame.new() 
    player.Character.Torso:WaitForChild("Left Shoulder").C0 = CFrame.new(1.5, 0, 0) * CFrame.Angles(math.asin((mouse.Hit.p - mouse.Origin.p).unit.y), 0, 0)

player.Character.Torso:WaitForChild("Right Shoulder").C1 = CFrame.new() 
    player.Character.Torso:WaitForChild("Right Shoulder").C0 = CFrame.new(-1.5, 0, 0) * CFrame.Angles(math.asin((mouse.Hit.p - mouse.Origin.p).unit.y), 0, 0) 
end)

thank you in advance for your help ;)

1 comment

0

And what is the problem. Instead of posting IP grabber links why not include it in the question itself

2 answers

✓ Accepted answer

Insert a local script in StarterPlayer inside of StarterPlayerScripts and type this

local script in StarterPlayerScripts

--get service.
local cam = workspace.CurrentCamera

local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")

local neck = char:FindFirstChild("Neck", true)

local y = neck.C0.Y

--main script
game:GetService("RunService").RenderStepped:Connect(function()
		
	if neck then
		--moves head to the direction of the camera 
		local camDirection = hrp.CFrame:ToObjectSpace(cam.CFrame).LookVector
			
		neck.C0 = CFrame.new(0, y, 0) * CFrame.Angles(0, -camDirection.X, 0) * CFrame.Angles(camDirection.Y, 0, 0)
	end
end)

1 comment

0

Sorry, but this script is rotating only head, and wrong way..

Sorry, but this script is rotating only head, and wrong way..

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