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

How do I make this script copy somebody's clothing and remove it, but then later restore it?

This script is supposed to allow a player to try on clothing before they buy it, but the only issue is that the clothing stays on them. I would like to have this script remove the player's pants, put on the pants that will be sold, wait for 5 seconds, then remove those pants and restore the original pants. I believe it sounds a lot more complicated than it should be. Any ideas?

local cd = script.Parent.ClickDetector
local pants = script.Parent.Parent.Parent.Char.Pants

cd.MouseClick:connect(function(player)
	if player.Character ~= nil then
		if player.Character:FindFirstChild("Pants") then
			player.Character["Pants"]:remove()
			pants:Clone().Parent = player.Character
		else
			pants:Clone().Parent = player.Character
		end
	end
end)

7 comments

0

Line 7 should be player.Character.Pants:Remove()

0

Thats deprecated tho you should use :Destroy() instead

0

Id instead tho set the parent of the pants to nil and then later set the parent of the pants to the player's character

0

I don't know how to do that, but I will try sorry just starting to learn how to script.

0

alright so here's what I've got so far:

0

I wasn't able to paste it into the post section so I had to put it as an answer

0

hey since you helped me, if you just copy and paste what I have down below, I can accept your answer so that you can get some credit. And if there is anything that you would change please feel free to let me know!

1 answer

local cd = script.Parent.ClickDetector
local pants = script.Parent.Parent.Parent.Char.Pants

cd.MouseClick:connect(function(player)
	if player.Character ~= nil then
		if player.Character:FindFirstChild("Pants") then
			player.Character["Pants"].Parent = game.ServerStorage
			pants:Clone().Parent = player.Character
			wait (5)
			player.Character.Pants:Remove()
			game.ServerStorage["Pants"].Parent = player.Character
		else
			pants:Clone().Parent = player.Character	
			wait (5)
			player.Character.Pants:Remove()
		end
	end
end)

I got it!!!!

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