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

How to remove the player's stuff when he dies?

Let's say I buy a boat and I load it

how do I make it so when i die my boat goes away. But I still have the option to load it when I respawn.

1 answer

I would a add a script with a global value that holds all possessions of the player. Add the script to the player at start and every time the player buys something add it to this array. Then add another global value that holds the possessions that are spawned.

_G[script].Possessions = {}
_G[script].Possessions.Spawned = {}

You may want to put this inside the serverStorage and clone it to every user that joins the game. Now when a player dies, loop through the spawned objects

-- change the key (_G[*THIS*].Possessions.Spawned) to the above's script location
for i, v in pairs (_G[script].Possessions.Spawned) do 
	v:Destroys()
end

Should be something like this, there are probably loads of other ways to do it, but this is what I can come up with. Good luck!

1 comment

0

I didnt understand that, can someone please explain? Thanks

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