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

Character glitching when changing the arm CFrame. How do I fix this bug?

Asked by 6 years ago

I have this script:

local function LookAtMouse()
      player.Character:WaitForChild("Right Arm").CFrame = CFrame.new(player.Character:WaitForChild("Right Arm").Position, mouse.Hit.p)
    end

When called, the character glitches.. Instead of ONLY the arm CFrame look at the mouse.Hit.p, the whole body moves that direction for a milisecond and then goes back to normal. Is it because of the animations of moving or what?

1 answer

Log in to vote
0
Answered by 6 years ago

This is a thing about player's characters. Since they have joints inside of them, when you move one part, all the parts move with them. A easy way to fix this is the following:

local arm = player.Character:WaitForChild("Right Arm") --get player's right arm
local newarm = arm:Clone()--clone it
newarm:ClearAllChildren() --get rid of all the joints in it
newarm.Anchored = true--anchor the part (cframe's dont work well with unanchored parts)
newarm.Name = "Rightt Arm"--name it something else
newarm.Parent = arm.Parent--put it in the plr's character
arm.Transparency = 1 ---make it non-visible


local function MoveTo(cframe)--this function will move the player's arm to the position
    arm.CFrame = cframe
end

Now, you could simply make the LookAtMouse like this:

local function LookAtMouse()
      MoveTo(CFrame.new(player.Character:WaitForChild("Right Arm").Position, mouse.Hit.p))
end

If your not doing this already, this would need to be run in a while wait() do loop or game:GetService("RunService").RenderStepped loop for it to be constantly updating, I hope I could help you with your problem,

-REALTimothy0812

0
I did it and it still bugs, and just makes the arm invisible wilsonsilva007 373 — 6y
Ad

Answer this question