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

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

Asked by 4 years ago
Edited 4 years ago

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 ;)

0
And what is the problem. Instead of posting IP grabber links why not include it in the question itself programmerHere 371 — 4y

2 answers

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

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)
0
Sorry, but this script is rotating only head, and wrong way.. Newh0hrizonCz 58 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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

Answer this question