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

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

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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!

0
I didnt understand that, can someone please explain? Thanks Nick1482 50 — 9y
Ad

Answer this question