My arm points towards my cursor just fine, until I rotate my character and this happens:
This is probably happening because the arm is relative to the camera and not the torso.
You should transform motor6D of the arm:
motor.Transform = CF...
Edit: You might’ve already done that cant tell lol.
You could just set rotations without positioning the arm
local Game = game
local RunService = Game:GetService("RunService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Torso = Character:FindFirstChild("Torso") or Character:WaitForChild("Torso")
local LeftShoulder = Torso:FindFirstChild("Left Shoulder") or Torso:WaitForChild("Left Shoulder")
local RightShoulder = Torso:FindFirstChild("Right Shoulder") or Torso:WaitForChild("Right Shoulder")
local function OnRenderStep()
LeftShoulder.C0 = CFrame.lookAt(LeftShoulder.C0.Position, Mouse.Hit.Position) * CFrame.Angles(math.pi / 2, 0, 0)
RightShoulder.C0 = CFrame.lookAt(RightShoulder.C0.Position, Mouse.Hit.Position) * CFrame.Angles(math.pi / 2, 0, 0)
end
RunService.RenderStepped:Connect(OnRenderStep)
1 Like
Didn’t work, arm was clipped inside character.
Was meaning to comment that a clamp would be required to prevent the arms from folding in on themselves.
1 Like
Tried to get clamp working with the orientation values of the arm relative to the hrp and it didn’t work. Here’s my function, if it helps:
local function updateArmPosition()
local point = mouse.Hit.Position
local char = game.Players.LocalPlayer.Character
local hrp = char:WaitForChild("HumanoidRootPart")
local newCFrame = CFrame.new(hrp.Position, point) * CFrame.Angles(math.pi/2, 0, 0)
main = hrp.CFrame:ToObjectSpace(newCFrame) * CFrame.new(1.5, -.5, -.5) --offsets arm from middle of plr
weld.C0 = main
end
I recommend using CFrame.lookAt
as it has a 3rd argument that lets you specify the UpVector.