Hello!
I am trying to make a function that welds some parts to the player rig based on another rig.
Problem is the welds Part1 always gets set to nil even though I print out the Part1 as expected.
Heres the script:
function module.ApplySkin(Rig,AddonRig,Clear)
local AddonFolder=AddonRig.Default
AddonFolder=AddonFolder:Clone()
AddonFolder.Parent=Rig
for i,Folder in AddonFolder:GetChildren() do
local FolderPart=AddonRig:FindFirstChild(Folder.Name)
local RigEquivelant=Rig:FindFirstChild(Folder.Name)
if not FolderPart or not RigEquivelant then continue end
for i,Part in Folder:GetDescendants() do
if not Part:IsA("BasePart") then continue end
local Weld = Instance.new("Weld")
local offsetC0 = Part.CFrame:Inverse() * FolderPart.CFrame
local offsetC1 = FolderPart.CFrame:Inverse() * Part.CFrame
print(offsetC0,offsetC1)
Part.Anchored=false
Weld.Parent=Part
Weld.Part0=Part
Weld.Part1=FolderPart
Weld.C0=offsetC1
Weld.C1=offsetC0
end
end
task.wait(1)
module.Entities[Rig].Skin=AddonFolder
end
Help would be much appreciated!