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

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

Asked by 9 years ago

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

0
I got downgraded -_- raspyjessie 117 — 9y

1 answer

Log in to vote
0
Answered by
RoboFrog 400 Moderation Voter
9 years ago

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.

0
I am not going to do the exact thing in this post but something like it ,Thanks raspyjessie 117 — 9y
Ad

Answer this question