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! :)
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.
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.