Hello developers,
This is my third post today, but I keep running into errors. I am very new to metatables / OOP in-general, so I may be completely wrong with how I am doing this script.
Module Script:
function MorphHandler:Weld(self, Character, CharacterBasePart, MorphEquipped)
if MorphHandler then
local Shirt, Pants = self.Shirt, self.Pants
Character.Shirt.ShirtTemplate = Shirt.ShirtTemplate
Character.Pants.PantsTemplate = Pants.PantsTemplate
for _, BaseParts in ipairs(self:GetChildren()) do
if BaseParts:IsA("Model") then
for _, Bases in ipairs(BaseParts) do
local ClonedBasePart = BaseParts:Clone()
if Bases.Name == ClonedBasePart.Name then
print(CharacterBasePart.Name)
ClonedBasePart.PrimaryPart.CFrame = CharacterBasePart.CFrame
local Weld = Instance.new("Weld")
Weld.Part0 = CharacterBasePart
Weld.Part1 = ClonedBasePart.PrimaryPart
ClonedBasePart.Parent = CharacterBasePart
Weld.Parent = ClonedBasePart.PrimaryPart
for _, PartsInBase in ipairs(ClonedBasePart:GetChildren()) do
PartsInBase.Anchored = false
end
end
end
end
end
end
end
Server Script:
MorphEquip.OnServerEvent:Connect(function(Player, MorphType)
local Character = Player.Character or Player.Character:Wait()
MorphEquipped = true
local function CharacterBaseParts()
local Table = {}
for _, BaseParts in ipairs(Character:GetChildren()) do
if BaseParts:IsA("BasePart") then
table.insert(Table, BaseParts)
end
end
return Table
end
local BaseParts = CharacterBaseParts()
MorphHandler:RemoveAccessorys(MorphType, Character, MorphEquipped)
MorphHandler:Weld(MorphType, Character, BaseParts, MorphEquipped)
if Character.Humanoid.Health == 0 then
MorphHandler:OnDeath(MorphEquipped)
end
end)
I am getting the error:
https://gyazo.com/4a9fdf99779767e172a965fec190053d
Line 31:
for _, Bases in ipairs(BaseParts) do