Arms getting stuck in position

Hey Guys!

I’m currently working on a project with a couple of buds and i’m working on the guns, now. I got this problem with the code. when you aim, we don’t use view model, we use c frame to change the arm position based of mouse position, and this happens once we enable the script. But the problem is once you disable the script, it looks like this.

Here is the code:

local plr = game.Players.LocalPlayer;
repeat wait() until plr.Character
local char = plr.Character
local m = plr:GetMouse()
game["Run Service"].RenderStepped:connect(function()
local c = game.Workspace.CurrentCamera
char.Torso["Right Shoulder"].C0 =,0.5,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y),1.55,0)
char.Torso["Left Shoulder"].C0 =,0.5,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y),-1.55,0)
char.Torso["Neck"].C0 =,1,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y) + 1.55,3.15,0)

Is there anyway to fix this, so the arms to back to normal?
Any help loved!

To solve this, I think you should save the original cframes of the character’s motor6ds before you change them and just reset them to that once you’re done.

I also noticed a couple other things with the script:

  1. You don’t need a wait(1) at the top of the script, the localplayer is always there.
  2. Instead of using repeat wait() until, you should use the CharacterAdded event.
  3. The way you’re getting the services is deprecated, you should use :GetService.
  4. :connect() is deprecated, you’re supposed to use :Connect().
  5. The script won’t work for r15 characters.
  6. .p is deprecated, you should use .Position.
  7. Same as above with .Unit instead of .unit.
  8. You should define camera once outside of the RenderStepped connection instead of every single frame.
  9. Please indent, it’ll make fixing the scripts easier for us and for yourself.
  10. Use proper variable names for the same reason as number 9.
  11. Save the math stuff in a variable instead of re-doing it every single time. This is especially important because the code runs like 60 times a second.
  12. The thing I said above also applies for the character’s body parts.
  13. The script will stop working once the character resets.

Here’s the script with the above things I mentioned fixed: (apart from the r15 thing)

local RunService = game:GetService("RunService")
local camera = workspace.CurrentCamera

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local mouse = plr:GetMouse()

local rightShoulder = char.Torso:FindFirstChild("Right Shoulder")
local leftShoulder = char.Torso:FindFirstChild("Left Shoulder")
local neck = char.Torso:FindFirstChild("Neck", true)

-- reset the c0s to these once u stop the renderstepped
local originalRightShoulderC0 = rightShoulder.C0
local originalLeftShoulderC0 = leftShoulder.C0
local originalNeckC0 = neck.C0

    local angleComponent = -math.asin((mouse.Origin.Position - mouse.Hit.Position).Unit.Y

    rightShoulder.C0 =, 0.5, 0) * CFrame.Angles(angleComponent, 1.55, 0)
    leftShoulder.C0 =, 0.5, 0) * CFrame.Angles(angleComponent, -1.55, 0)
    neck.C0 =, 1, 0) * CFrame.Angles(angleComponent + 1.55, math.pi, 0)

    rightShoulder = newChar.Torso:FindFirstChild("Right Shoulder")
    leftShoulder = newChar.Torso:FindFirstChild("Left Shoulder")
    neck = newChar.Torso:FindFirstChild("Neck", true)
1 Like