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

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

Asked by 5 years ago
Edited 5 years ago

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)

0
Line 7 should be player.Character.Pants:Remove() TiredMelon 405 — 5y
0
Thats deprecated tho you should use :Destroy() instead TiredMelon 405 — 5y
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 TiredMelon 405 — 5y
0
I don't know how to do that, but I will try sorry just starting to learn how to script. KingCheese13 21 — 5y
View all comments (3 more)
0
alright so here's what I've got so far: KingCheese13 21 — 5y
0
I wasn't able to paste it into the post section so I had to put it as an answer KingCheese13 21 — 5y
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! KingCheese13 21 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
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!!!!

Ad

Answer this question