What do you want to achieve? I want the arm to point towards the mouse position
What is the issue? When I aim downwards it spazzes out
What solutions have you tried so far? I found this on the toolbox and i tried to use math.clamp on it but it didn’t end up fixing the issue just limiting its range of motion, i want it to be able to point down and even inside the player but why is it spazzing out?.
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local RunService = game:GetService("RunService")
local Torso = Character:WaitForChild("Torso")
local RightShoulder = Torso:WaitForChild("Right Shoulder")
local LeftShoulder = Torso:WaitForChild("Left Shoulder")
local LeftArm = Character:WaitForChild("Left Arm")
local RightArm = Character:WaitForChild("Right Arm")
local function Point_C0_To_Mouse(Motor6D, WorldCFrame)
local Part1_CFrame = Motor6D.Part1.CFrame
local Stored_C1 = Motor6D.C1
local Stored_C0 = Motor6D.C0
local RelativeTo_Part1 = Stored_C0 * Stored_C1:Inverse() * Part1_CFrame:Inverse() * WorldCFrame * Stored_C1
RelativeTo_Part1 -= RelativeTo_Part1.Position
local Goal_C0 = RelativeTo_Part1 + Stored_C0.Position
return Goal_C0
end
RunService.Stepped:Connect(function()
local Mouse_Pos = Mouse.Hit.Position
RightShoulder.C0 = Point_C0_To_Mouse(RightShoulder, CFrame.lookAt(RightArm.Position, Mouse_Pos)) * CFrame.Angles(0,0, math.deg(-90))
end)
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local RunService = game:GetService("RunService")
local Torso = Character:WaitForChild("Torso")
local RightShoulder = Torso:WaitForChild("Right Shoulder")
local LeftShoulder = Torso:WaitForChild("Left Shoulder")
local LeftArm = Character:WaitForChild("Left Arm")
local RightArm = Character:WaitForChild("Right Arm")
local function Point_C0_To_Mouse(Motor6D, target)
local Part0CFrame = Motor6D.Part0.CFrame
local Stored_C1 = Motor6D.C1
local Stored_C0 = Motor6D.C0
local origin = Part0CFrame * Stored_C0
local lookAt = CFrame.new(origin.Position, target) * CFrame.Angles(math.rad(90), math.rad(90), 0)
return origin:Inverse() * lookAt
end
RunService.PreSimulation:Connect(function(dt)
local Mouse_Pos = Mouse.Hit.Position
RightShoulder.Transform = Point_C0_To_Mouse(RightShoulder, Mouse_Pos)
end)
btw it’s math.rad when you want the radians from degrees. this mistake cost me my sanity
if you need any explanations ask and i’ll try but im not really good at this lol
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local RunService = game:GetService("RunService")
local Torso = Character:WaitForChild("Torso")
local RightShoulder = Torso:WaitForChild("Right Shoulder")
local LeftShoulder = Torso:WaitForChild("Left Shoulder")
local LeftArm = Character:WaitForChild("Left Arm")
local RightArm = Character:WaitForChild("Right Arm")
local function Point_C0_To_Mouse(Motor6D, target)
local Part0CFrame = Motor6D.Part0.CFrame
local Stored_C1 = Motor6D.C1
local Stored_C0 = Motor6D.C0
local origin: CFrame = Part0CFrame * Stored_C0
local lookAt = CFrame.new(origin.Position, target) * CFrame.Angles(math.rad(90), math.rad(90), 0)
origin -= lookAt.LookVector * 0.5
local lookAt2 = CFrame.new(origin.Position, target) * CFrame.Angles(math.rad(90), math.rad(90), 0)
return origin:Inverse() * lookAt2
end
RunService.PreSimulation:Connect(function(dt)
local Mouse_Pos = Mouse.Hit.Position
RightShoulder.Transform = Point_C0_To_Mouse(RightShoulder, Mouse_Pos)
end)
btw this is if you want the “palm” to be looking at the point rather than just the arm looking along it, which is this