local pants = script.Parent.Pants.PantsTemplate
local shirt = script.Parent.Shirt.ShirtTemplate
--------
local function removeAllParts(hit)
hit.Parent.Head.face.Texture = ""
hit.Parent.Pants.PantsTemplate = pants
hit.Parent.Shirt.ShirtTemplate = shirt
for i, v in pairs(hit.Parent:GetChildren()) do
if v:IsA("Accessory") then
v:Destroy()
end
end
end
local function createWelds(hit)
local chr = hit.Parent
for i,v in pairs(script.Parent.Parent:GetChildren()) do
if v:IsA("Model") then
v.PrimaryPart = v.Middle
local clone = v:Clone()
if v.Name == "Eyes" then
clone:SetPrimaryPartCFrame(chr.Head.CFrame)
elseif v.Name == "Leg1" then
clone:SetPrimaryPartCFrame(chr["Left Leg"].CFrame)
elseif v.Name == "Leg2" then
clone:SetPrimaryPartCFrame(chr["Right Leg"].CFrame)
elseif v.Name == "Chest" then
clone:SetPrimaryPartCFrame(chr.Torso.CFrame)
elseif v.Name == "Arm1" then
clone:SetPrimaryPartCFrame(chr["Left Arm"].CFrame)
elseif v.Name == "Arm2" then
clone:SetPrimaryPartCFrame(chr["Right Arm"].CFrame)
end
end
end
end
script.Parent.Touched:Connect(function(hit)
removeAllParts(hit)
createWelds(hit)
end)
The error arises in the createWelds function, where it doesn't seem to clone the parts, or place them at the characters bodypart positions
