ClickDetector Help

Alright, send me the main script then.

main script of what sir

The one for the click detector and that removes the parts.

local pantsId = script.Parent.Parent.Coathanger.Pants.PantsTemplate
local shirtId = script.Parent.Parent.Coathanger.Shirt.ShirtTemplate
local cPart = script.Parent
local cDetector = script.Parent.ClickDetector

local function playSoundLocal(sId,sParent)
	local sound = Instance.new("Sound",sParent)
	sound.SoundId = "http://www.roblox.com/asset/?id="..sId
	sound:Play()
	sound:Destroy()
end

local function onClicked(player)
	print(player.Name.." clicked on Uniform Giver")
	
	playSoundLocal(152206246,player)	-- Declaring the sound ID and Parent
	
	
	
	
	local foundShirt = player.Character:FindFirstChild("Shirt") -- Tries to find Shirt
	if not foundShirt then -- if there is no shirt
		print("No shirt found, creating for "..player.Name)
		local newShirt = Instance.new("Shirt",player.Character)
		newShirt.Name = "Shirt"
	else if foundShirt then -- if there is a shirt
		print("Shirt found, reconstructing for "..player.Name)
		player.Character.Shirt:remove()
		local newShirt = Instance.new("Shirt",player.Character)
		newShirt.Name = "Shirt"
	end
	end
	
	
	
	
	local foundPants = player.Character:FindFirstChild("Pants") -- Tries to find Pants
	if not foundPants then -- if there are no pants
		print("No pants found, creating for "..player.Name)
		local newPants = Instance.new("Pants",player.Character)
		newPants.Name = "Pants"
	else if foundPants then -- if there are pants
		print("Pants found, reconstructing for "..player.Name)
		player.Character.Pants:remove()
		local newPants = Instance.new("Pants",player.Character)
		newPants.Name = "Pants"
	end
	end
	
	player.Character.Shirt.ShirtTemplate = shirtId
	player.Character.Pants.PantsTemplate = pantsId
	end




local function onHoverEnter(player)
	cPart.Transparency = 1
	cPart.BrickColor = BrickColor.White()
end



local function onHoverLeave(player)
	cPart.BrickColor = BrickColor.Gray()
	cPart.Transparency = 1
end


-- Binds --

cDetector.MouseHoverEnter:connect(onHoverEnter)
cDetector.MouseHoverLeave:connect(onHoverLeave)
cDetector.MouseClick:connect(onClicked)

Just this script should change clothes and remove accessiores expect head and face

Alright, thank you.

This will be a little messy, as there is not an easy way to remove non-hats.

This should remove Body Accessories only:

local listOfStrings = {"Back", "Front", "Jacket", "LeftShoe", "RightShoe", "Pants", "Shirt", "Shorts", "Shoulder", "Sweater", "Waist", "Unknown"}

local function RemoveBodyAccessories(character)
	for _, A in pairs(character:GetChildren()) do
		if A:IsA("Accessory") then
			for _,v in ipairs(listOfStrings) do
				print(v)
				print(tostring(A.AccessoryType))
				if string.find(tostring(A.AccessoryType), v) then
					A:Destroy()
				end
			end

		end
	end
end

RemoveBodyAccessories(script.Parent)

The script could be made more efficient, but I don’t have time for that right now, but I’m pretty sure it works!


Remember to mark it as solution if it works!

Image from Gyazo

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.