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

Is there a way to save variables after a player dies?

I was just wondering if it is possible to save script variables in a script

1 comment

0

I got downgraded -_-

1 answer

✓ Accepted answer

Potentially. I've done similar things before, but it'll require modifying your entire place to allow it to work.

Basically, if you're up for it, what you can do is make a string value for each possible player slot, set all of their values to a specific word, and place it into lighting. Then, whenever a player joins, it'll check for the first open variable (by checking for the first value containing the "default word"), then change that word into the players name.

You can then store all of the variables per player in this string variable, creating a "model" of sorts. Whenever you want to reference a variable inside of this, you'll have to first check for the first variable with a name matching the players name (player.Name, hit.Name, maybe LocalPlayer.Name, et cetera), then it can look inside of the correctly matching string value for the needed value.

Whenever a player leaves, make it find the value matching the player's name, set the string value to the default word, and any values inside to the default values. This will then open up the slot for any joining players.

Cons to this include a lot more required scripting, it's more advanced than most people like to handle, and can be fully messed up when ROBLOX servers mess up and allow an extra player into a server.

Pros to this include saved variables (of course), the ability to quickly check the variables from any player, and a huge boon to certain inventory systems.

If you'd like a bit more explanation on a specific piece of the answer, just let me know -- I'll see what I can do.

1 comment

0

I am not going to do the exact thing in this post but something like it ,Thanks

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