Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Change Clothes Script (On Touch) Not Working? [closed]

Asked by 8 years ago

This question already has an answer here:

Change Clothes Script (On Touch) Not Working?

Hi, I got this model script, because I can't script at all and it just makes my character naked.


--theRal

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=190791972" 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=190791942" wait(1) worker = false end end end end

script.Parent.Touched:connect(onTouch)


Marked as Duplicate by InfinitivePixelsJr, User#11440, and User#6546

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 8 years ago
local shirtid = 12786197 -- change it to your shirt id (don't delete any numbers from shirt id)
local pantsid = 142080544 -- change it to your pants id (don't delete any numbers from pants id)

function kill(nam, parent) if parent:FindFirstChild(nam) then
    parent[nam]:Destroy()
end end

script.Parent.Touched:connect(function(p) 
    local Character =game.Players.LocalPlayer.Character
    kill("roblox", Character.Torso)
    kill("Shirt", Character)
    kill("Pants", Character)
    local s = Instance.new("Shirt")
    s.Parent = Character
    s.ShirtTemplate = "http://www.roblox.com/asset/?id="..(shirtid - 1)
    local t = Instance.new("Pants")
    t.Parent = Character
    t.PantsTemplate = "http://www.roblox.com/asset/?id="..(pantsid - 1)

end)

Hope this helps, if it did - Vote this answer up and accept it as an answer.

Ad