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

Best way to store player data? (not permenantly)

Asked by 4 years ago

Hi all,

I'm not sure this is really a scripting question but this community is great when it comes to these kinds of things.

So, for example, if I have a game with 6 resource types (like wood, stone, etc. or soemthing) and I wanted to store how much each player has (in the current game, not datastore stuff) would it be better to...

1) have a folder in replicated storage that I clone into the player when they enter. This would have int values to store the number of each currency they have. So if I want them to gain wood for chopping a tree I would increase that int value etc.

2) have a script with a dictionary of all of the players and has a table within that dictionary entry with all of their stats? where would i store a table like this? would it just be a normal script in storage or...?

I am comfortable doing either but I am wondering which you would personally go for, if there are any other options and which is the easiest/best.

Thanks guys! :)

0
Option 1 would be most effective. Robowon1 323 — 4y

2 answers

Log in to vote
1
Answered by
Nanomatics 1160 Moderation Voter
4 years ago
Edited 4 years ago

The safest way to achieve this and the way that I recommend would be to use a server script to manage that.

The reason behind that is that it is much safer to handle that using a server script because let us say an exploiter was able to enter your game and was trying to modify their resources, they would be able to access it since it's under the player, (most exploits can't access the server-sided aspects).

That being said, the best way to do it is handle the data of the players in a table that you have that can be indexed with their userid and whenever you need to remove/reward points you modify those values in the server script, and then you can make IntValues/NumberValues/StringValues when the player joins and update them according to the data you have for that player on the server script, that way even if they're able to modify that value, it does not mean anything, because the real values are in the server script. The purpose of making these values and updating them accordingly is to be able to read by the client in case you want to show how much resources they have on their screen, they're going to be read-only changing them through the client will not result in anything.

Hope I was clear enough, please let me know if you have further questions.

0
Thanks for your input! Yea I ws a bit concerened about security but I didn't even think about that way of doing things. With this serverscript, does it matter where I store it? When a player enters shall i literally just do something like... p = {}, p[player.UserId] = {}, p[player.UserId]["rss"] = {}. p[player.UserId]["rss"]["gems"] = 0? Also when I want to update their values, how will I do that? AlexTheCreator 461 — 4y
0
Would it be useful to use a modular script so I can call it from anywhere to update the values? Sorry for all the questions, thanks! AlexTheCreator 461 — 4y
0
Yeah it's exactly like that, and when you want to update it you would make a function that basically does p[player.UserId]["rss"]["gems"]=p[player.UserId]["rss"]["gems"] + increment and then you can call this function on whatever player with whatever stat with whatever increment, and yes you a module script would the best thing you can do so you can call the function from all serverscripts not one Nanomatics 1160 — 4y
0
No problem, im here to help! Nanomatics 1160 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

I would recommend doing the first option, It's a lot easier to do and I'm pretty sure most games that do some sort of system that requires saving does it as well. (Including me!)

That's just from my perspective, though. I just find it a lot easier. In terms of performance, probably the dictionary idea would be marginally better though. It's your choice in the end.

0
Thanks for your input! AlexTheCreator 461 — 4y

Answer this question