So I have a script where it gets rid of the hat that the player wears but I have a script where when a block is touched it changes the clothes and adds a hat but the hat part wont work here is the script.

|Script|

worker = false
part = script.Parent

function onTouch(hit)
    local human = hit.Parent:FindFirstChild("Humanoid")
    if (human ~= nil) and (worker == false) then
        print ("Success")
        worker = true
        wait(.1)
        local pant = hit.Parent:GetChildren()
        for i=1,#pant do
        if (pant[i].className == "Pants") then
            pant[i].PantsTemplate = "http://www.roblox.com/asset/?id=1139845426"
        end
     end
    local shirt = hit.Parent:GetChildren()
    for i=1,#shirt do
    if (shirt[i].className == "Shirt") then
        shirt[i].ShirtTemplate = "http://www.roblox.com/asset/?id=1630769803"
    end
 end
 local accessory = hit.parent:GetChildren()
 for i=1,#accessory do
 if (accessory[i].className == "Accessory") then
     accessory[i].accessory = "https://web.roblox.com/catalog/416833190/Tokyokhaos-Lion"
     wait(1)
     worker = false
     end
   end
 end
end
script.Parent.Touched:connect(onTouch)

Every thing else works but not the hat part!

1 comment

0

nice free models