The arms won’t follow the mouse when an animation plays. I want the arms to follow the mouse no matter what.
This is when i stand still:
This is when i move and my walking animation plays:
I’ve tried using a bunch of scripts that make the arms follow the cursor, but they all get messed up during my animation where the character slightly leans forward.
This is the localscript i use. It fires an event that causes the head and arms to follow the mouse and tween to the next position in a server script.
local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local lookEvent = script:WaitForChild("LookEvent")
local toolEvent = script:WaitForChild("ToolEvent")
local Character = Player.Character
local Root = Character:WaitForChild("HumanoidRootPart")
local Neck = Character:FindFirstChild("Neck", true)
local Torso = Character:WaitForChild("Torso")
local RightShoulder = Torso:FindFirstChild("Right Shoulder", true)
local LeftShoulder = Torso:FindFirstChild("Left Shoulder", true)
local YOffset = Neck.C0.Y
local NeckCFrame
local RightShoulderCFrame
local LeftShoulderCFrame
local CFNew, CFAng = CFrame.new, CFrame.Angles
local asin = math.asin
local equipped = false
Character.ChildAdded:Connect(function(child)
if child:IsA("Tool") and child:FindFirstChild("BodyAttach") then
equipped = true
end
end)
Character.ChildRemoved:Connect(function(child)
if child:IsA("Tool") and child:FindFirstChild("BodyAttach") then
equipped = false
RightShoulderCFrame = CFrame.new(1, 0.5, 0) * CFrame.Angles(0, math.pi/2, 0)
LeftShoulderCFrame = CFrame.new(-1, 0.5, 0) * CFrame.Angles(0, -math.pi/2, 0)
toolEvent:FireServer(RightShoulder,RightShoulderCFrame, LeftShoulder,LeftShoulderCFrame,"unequip")
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
local CameraDirection = Root.CFrame:toObjectSpace(Camera.CFrame).lookVector
if Neck then
NeckCFrame = CFNew(0, YOffset, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(0, 0, -asin(CameraDirection.x)) * CFAng(-asin(CameraDirection.y), 0, 0)
lookEvent:FireServer(Neck, NeckCFrame)
end
local mouseOrigin = Mouse.Origin
local mouseHit = Mouse.Hit
if RightShoulder and LeftShoulder then
if equipped then
RightShoulderCFrame = CFrame.new(1,0.5,0) * CFrame.Angles(-math.asin((mouseOrigin.p - mouseHit.p).unit.y),1.55,0)
LeftShoulderCFrame = CFrame.new(-1,0.5,0) * CFrame.Angles(-math.asin((mouseOrigin.p - mouseHit.p).unit.y),-1.55,0)
toolEvent:FireServer(RightShoulder,RightShoulderCFrame, LeftShoulder,LeftShoulderCFrame, "equip")
end
end
end)
I’ve been trying to figure this out for a while now and would appreciate some help. Thanks.