I’m debating on how should I make the data sharing between server and client work, i thought of 2 solutions and I’m not sure which will be the most efficient one performance-wise. so i have all players data on the server, for example:
allPlayersData = {
[player1.UserId] = {level = 1, gold = 5, items = ["wooden sword"]},
[player2.UserId] = {level = 5, gold = 50, items = ["steel sword"]}
}
now, player1 can see player2 data only when they are clicking their username on leaderboard, but they can see their level all of the time because it’s shown on the leaderboard.
i thought of 2 options of how to make it work.
-
make player request
allPlayerData
for the first time and then listen to change events that is fired from the server to all clients whenever a piece of data have been changed, which for me sounds like it could be a performance issue because there will be a lot of event fires from the server to clients. -
have a level intValue under every player, so that the player that wants to know the level of the other player can just read it from there, and only when player presses specific player on the leaderboard it’ll send request to the server to get that players data, the answer could be slow, but i feel like it’ll be a little more efficient then option 1.
i’m not sure which option i should go with, or is there a better option?
also another question, how do i access data (that is stored in a variable) that for example LocalScript1 got from the server from LocalScript2? it’s so that i wouldn’t have to request data from server on every localscript.