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

SetAsyncing data without calling again? [UNANSWERED]

Asked by 8 years ago

Hey all! I have a script in ServerScriptService with all the DataStores in my game defined and all self updating - how can I "Re-use" this in other scripts by "SetAsyncing" data using that script without having to recall the DataStores?


local OilRigData = game:GetService("DataStoreService"):GetDataStore("BestOilRigOverall") local OilRigDataUserId = game:GetService("DataStoreService"):GetDataStore("BestOilRigOverallUserId") local data = {dataone = OilRigData:GetAsync("BestOilRigOverall"), datatwo = OilRigDataUserId:GetAsync("BestOilRigOverallUserId")} local OilRigConnection = OilRigData:OnUpdate("BestOilRigOverall", function(newValue) data.dataone = newValue end) local OilRigUserIdConnection = OilRigDataUserId:OnUpdate("BestOilRigOverallUserId", function(newValue) data.datatwo = newValue end) function game.ReplicatedStorage.RemoteFunctions.GetData.OnServerInvoke(player) return data end

From another script I can "GetAsync" this data by Firing a RemoteFunction and print(data.dataone) but how can I use this (or a similar script) to Set Astnc the DS's in a similar way? Preferably I would like to do something like data.dataone = 122 if possible! :slightly_smiling:

Any tips/help appreciated. Thanks!

0
I'm not exactly sure what you mean by your question. Could you elaborating a bit more or maybe provide an example? dyler3 1510 — 8y
0
Sure, I did! :) Let me know if it is still not clear! jjwood1600 215 — 8y
0
I think OP wants it so that they don't have to do :GetAsync() every time they want to retrieve the data. XAXA 1569 — 8y
0
No no no - I want to do it so I don't have to Call the data every time and I want to have an easy way using the above script that I can call from anywhere to SetAsync if you get what I mean? That means I only have the one datastore request for the whole server lifetime! ;) jjwood1600 215 — 8y

Answer this question