Hello,
I have an GUI shop where you can buy stuff. So my question is. Example, I buy Gravity Coil then it stays until I leave from Game.
My question is, I've tried to make a code which will remove everything from Backpack when you've died 3 times.
if Player.leaderstats.Deaths.Value == 3 then Player.leaderstats.Deaths.Value = Player.leaderstats.Deaths.Value - 3 Player.Backpack:ClearAllChildren()
Right now it only removes one item from Backpack, but if you respawn then it comes back. How can I fix that? Thanks!
Why don't you use a In pairs loop to loop through all the tools in Backpack
and Destroy()
them?
if Player.leaderstats.Deaths.Value == 3 then for _,v in pairs(Player:WaitForChild("Backpack"):GetChildren()) do v:Destory() end end
~UserOnly16Charcters, Hoped I helped you to answer your question! If you have any further question, don't hesitate to comment below!!
Edited:
This script delete the Weapons from the StarterGear
if Player.leaderstats.Deaths.Value == 3 then for _,v in pairs(Player:WaitForChild("StarterGear"):GetChildren()) do v:Destory() end end