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

Why does changing C1 of this weld teleports the part randomly around my character?

Asked by 7 years ago

I'm trying to create fake arms for my gun kit, because I've decided it's the easiest way to make animations (because I can't find a way to make the arms not move). I've got them to work, but whenever I try to angle the C1 of the weld that connects the fake arm to the torso, it teleports around the character. Does anyone know how to fix this?

Here's the code to the fake arms

local player = game:GetService("Players").LocalPlayer
local character = player.CharacterAdded:wait()
local rightArm,leftArm = character:WaitForChild("Right Arm"),character:WaitForChild("Left Arm")
local rightWeld,leftWeld = Instance.new("Weld",character:WaitForChild("Torso")),Instance.new("Weld",character:WaitForChild("Torso"))
local fakeArms = Instance.new("Model",character)
local fakeRightArm,fakeLeftArm = Instance.new("Part",fakeArms),Instance.new("Part",fakeArms)
fakeArms.Name = "fakeArms"
fakeRightArm.Name = "Right Arm"
rightWeld.Name = "rightWeld"
fakeRightArm.Size = rightArm.Size
fakeRightArm.CFrame = character:WaitForChild("Torso").CFrame
fakeRightArm.CanCollide = false
rightWeld.C0 = character:WaitForChild("Torso").CFrame:inverse() * CFrame.new(1.5,0,0):inverse()
rightWeld.Part0 = character:WaitForChild("Torso")
rightWeld.C1 = fakeRightArm.CFrame:inverse()
rightWeld.Part1 = fakeRightArm
fakeLeftArm.Name = "Left Arm"
leftWeld.Name = "leftWeld"
fakeLeftArm.Size = leftArm.Size
fakeLeftArm.CFrame = character:WaitForChild("Torso").CFrame
fakeLeftArm.CanCollide = false
leftWeld.C0 = character:WaitForChild("Torso").CFrame:inverse() * CFrame.new(-1.5,0,0):inverse()
leftWeld.Part0 = character:WaitForChild("Torso")
leftWeld.C1 = fakeLeftArm.CFrame:inverse()
leftWeld.Part1 = fakeLeftArm

Here's the code to angle the arms workspace.Player1.Torso.leftWeld.C1 = workspace.Player1.Torso.leftWeld.C1 * CFrame.Angles(math.rad(10),0,0)

Thanks!

Answer this question