Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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)


1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.