Historically for player data, I’ve created a folder for them in ServerStorage/ReplicatedStorage and put their values/stats in there. Assuming FE and sanitation checks for all remote events, is that still a good way to do things? I’ve seen some talk about storing player data in tables but I’m not entirely sure how that would work without having a million remote events firing every second.
Basically my question is: what is the best way to store and retrieve player data in-game?
imalex4
(imalex4)
May 29, 2020, 3:28pm
#2
I am assuming the data is only needed until the player leaves, and you are not using a data store.
This is how I would store player data.
playerdata = {} --a table of tables
playerdata.imalex4 = {}
playerdata.imalex4.points = 43
playerdata.imalex4.deaths = 0
playrdata.Avatar_Korra = {}
playrdata.Avatar_Korra.points = 0
playrdata.Avatar_Korra.deaths = 43
1 Like
But if both the server and client(s) need to access that data, how would both of them access it?
i.e. If the table is made in a Script, then how would the client get access to it and when things change, and vice versa?
imalex4
(imalex4)
May 29, 2020, 3:33pm
#4
Use a remote function to ask for the data. You just need one remote function inside ReplicatedStorage.
1 Like
Oh, I didn’t know tables were passed by reference like that. Thanks!
The client should never have access to editing data.
You can allow the client to view changes made to the data via RemoteEvents, or (if you’re lazy) object values. It’s better practice to use RemoteEvents/RemoteFunctions though.
https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
https://developer.roblox.com/en-us/api-reference/class/StringValue
Also, in terms of performance, it’s best to use multiple RemoteEvents/RemoteFunctions instead of sending some sort of ID through the network.
We can measure how much data a remote needs to send in bytes. Basically each character in a string is one byte, so “ExampleRemoteKey” would send at least 16 bytes because it has 16 characters. When numbers are used, it needs to replicate a double which is 8 bytes long.
It’s a little more complicated than this though. Roblox also needs to send the value’s type as well as string lengths. There are cases where a string can use less data than a number, and there are cases where a number can use les…
Intro
Network.lua (26.3 KB) - Alternatively you can grab the file
Hey everyone, we built a decent shared network module for The Wild West, and I wanted to release it as a free resource for you guys.
This can be especially useful for new developers or old developers daunted by switching over to Filtering Enabled!
This is a single module that you slap into ReplicatedStorage, and it just works. It mimics functionality of Remote Events/Functions, without you having to create them manually.
N…
1 Like