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

Best Way to View Data From the Client?

Asked by 1 year ago

Right now, I am very satisfied with the way I am handling the client viewing the server's data. In essence, the player's data (dictionary) is 'converted' to folders and attributes for the client's viewing sake. So, the dictionary would look like this:

{

Stats = {
Money = 300,
Exp = 200,
},

Others = {
TypeA = 'Hi',
TypeB = 'Bye',
},

}

And the final result would look something like this:

Stats (Folder) Attribute: Money, 300 Attribute: Exp, 200

Others(Folder) Attribute: TypeA, 'Hi' Attribute: TypeB, 'Bye'

Not only that, but when the data is updated, the values are updated/overwritten as well. This allows the client to listen in without any remotes. I find this system almost flawless (to me), but an issue has arisen. This works well with changing and adding values... but not well with deleting them.

This is especially annoying when the values won't delete themselves when you remove them from the array. Especially in inventories! For example, say you sell an item and it removes the value from the array on the server. And then, it doesn't remove itself from the folders, causing the client to still think they have an item (only visually). How would I detect this change, or in other words, is there any ways to replicate constantly-changing dictionaries to folders? I have tried deleting the folders on every change (which does work), but the client listening in with changed signals get deleted, and that defeats the whole purpose. I'd love some input; thank you!

0
Remote Events MattVSNNL 620 — 1y

2 answers

Log in to vote
0
Answered by 1 year ago

You can't really view data at all, but if you're asking how to send it across scripts then your best bet is doing it via RemoteEvents

Ad
Log in to vote
0
Answered by
xXMadonXx 190
1 year ago

The answer you want: If you are not using Remote Events, use the Values inside the Folder as Dictionary and not an actual Dictionary (as in Table) and create a local-side listener for ChildRemoved. Also you need RemoteEvents to get info from Client to server.

The truth: You need to start using RemoteEvents. Syncing a Table between client and server is only 3 Lines of code (on both sides) with RemoteEvents. Also you then have cleaner code and overall more simplicity as you are using complicated dictionarys and not just simple values.

Using Value-Objects as Storage is bad practice. You are introducing a whole lot of potential problems.

Also you are going to need RemoteEvents at some point in time so why not start now?

Answer this question