Try this version of the script with the print statements added:
local button = script.Parent.Button
local clicker = button.ClickDetector
clicker.MaxActivationDistance = 25
local item = script.Parent.Item
local function giveAccessory(player)
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
for _, v in pairs(char:GetChildren()) do
print(1)
if v.ClassName == "Shirt" and v:IsA("Shirt") then
print(2)
v:Destroy()
end
end
for key, obj in pairs(char:GetChildren()) do
print(3)
if obj:IsA("Accessory") then
print(4)
local accessory = obj
local handle = obj:FindFirstChild("Handle")
for i,v in pairs(handle:GetChildren()) do
print(5)
if v.Name == "BodyFrontAttachment" and v:IsA("Attachment") then
print(6)
accessory:Destroy()
end
end
end
end
local clonedItem = item:Clone()
clonedItem.Handle.Anchored = false
hum: AddAccessory(clonedItem)
end
clicker.MouseClick:Connect(giveAccessory)
shirt-stuff.rbxl (52.3 KB)
Check out this place i made, it might help. I created a physical button that changes your shirt, a physical button that removes it, and a gui button that resets your shirt to your original shirt.
I appreciate it, but the thing is I am having a hard time getting any button to remove the Shirt versus removing 3D layered clothing, like attachments/accessories. My shirts and pants in game are all attachments, wherein some players original clothes will be classic and others will be layered, if that makes sense
I think I am just misunderstanding what you are saying. Can you just sum up everything that is supposed to happen when you press the “reset clothes/reset shirt” button?
So here’s what is suppose to happen. Player clicks on a shirt (or pants). The shirt the player is wearing is replaced w/the new shirt. There is a screengui where the player can click reset shirt, and their original shirt when they joined the game is put back on.
This all works the first time I run it. It’s after I reset my shirt to the original and then try to click on a shirt, it does not remove my original shirt anymore. It still adds the new shirt, just on top of my og shirt. Here’s the vid.
It would be helpful if you could show the print results for each step of the situation. For example, when you first equip an item fresh from joining the game, show the print results. Then, proceed to the next step of the issue and reset your shirt. Show the print results for that. Then equip another accessory. Show print results. Then finally reset the shirt again and see the print results.
*and make sure to separate each step so we can tell the difference!
Here is what happens when I just click on the new shirt one time. Nothing else clicked or done
15:10:41.731 1 (x8) - Server - giveAcc:11
15:10:41.732 2 - Server - giveAcc:13
15:10:41.733 1 (x16) - Server - giveAcc:11
15:10:41.735 3 (x8) - Server - giveAcc:19
15:10:41.736 4 - Server - giveAcc:21
15:10:41.736 5 (x4) - Server - giveAcc:25
15:10:41.737 3 (x15) - Server - giveAcc:19
15:10:41.741 4 - Server - giveAcc:21
15:10:41.741 5 (x4) - Server - giveAcc:25
quick question, are all changes applied to shirts (creating, destroying, etc.) being done on the server? Or are some changes applied only on the client (local scripts)?
putting the new shirt on and destroying the shirt are done on a regular script by clicking the shirt in the workspace.
The storing of the shirttemplate and the reset of the original shirt is done both by a localscript under screengui and a regular script in serverscriptservice
Yes. But your issue is that the accessories don’t remove Shirts after they did once already. So, you want to see the difference in print statements between a regular accessory equip event (you already posted that) and what happens once you try again (which you have not posted yet).
does the localscript or the regular script do the actual removal/addition of the shirt when resetting? Like which script has the line of code that deletes the shirt and adds the original one?
so when resetting there is a local script and a server script. I had attached them in the beginning of the thread. Let me know if I should insert them again.