Hi everyone,I was scripting a team change clothing script that when a player touch it change the character clothing based him/her team, unfortunatly the script don’t work at all,it only delete character clothings without adding new clothes.
I’ve worked for 2 days and it still doesn’t work,I tried a lot of things but no one of them worked,I want that the script change character clothings when it touch the change clothes part.
Here’s the scripts:
local me = script.Parent
local shirt = me.DefenderShirt
local pants = me.DefenderPants
local function giveClothes(p)
local model = p.Parent
if model:FindFirstChildWhichIsA("Pants") then
model:FindFirstChildWhichIsA("Pants"):Destroy()
local p = pants:clone()
p.Parent = p.Parent
print("Don't work")
else
local np = pants:clone()
np.Parent = np.Parent
print("Works")
end
if model:FindFirstChildWhichIsA("Accessory") then
model:FindFirstChildWhichIsA("Accessory"):Destroy()
local s = shirt:clone()
s.Parent = p.Parent
else
local ns = shirt:clone()
ns.Parent = p.Parent
end
if model:FindFirstChildWhichIsA("Shirt") then
model:FindFirstChildWhichIsA("Shirt"):Destroy()
end
end
me.Touched:Connect(giveClothes)
local me = script.Parent
local shirt = me.DefenderShirt
local pants = me.DefenderPants
local function giveClothes(p)
for i, v in pairs(p.Parent:GetChildren()) do
if v:IsA("Shirt") then
v.ShirtTemplate = shirt.ShirtTemplate
elseif v:IsA("Pants") then
v.PantsTemplate = pants.PantsTemplate
end
end
end
me.Touched:Connect(giveClothes)
local me = script.Parent
local shirt = me.DefenderShirt
local pants = me.DefenderPants
local function giveClothes(hit)
local hitModel = hit:FindFirstAncestorOfClass("Model")
if hitModel then
local hitHuman = hitModel:FindFirstChildOfClass("Humanoid")
if hitHuman then
local hitShirt = hitModel:FindFirstChildOfClass("Shirt")
if hitShirt then
hitShirt.ShirtTemplate = shirt.ShirtTemplate
end
local hitPants = hitModel:FindFirstChildOfClass("Pants")
if hitPants then
hitPants.PantsTemplate = pants.Template
end
end
end
end
me.Touched:Connect(giveClothes)