Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I be able to auto update a datastore value?

I'm trying to make the following script auto update a datastore value. I am using multiple servers / universes that change the datastore value which is the problem, i'd need to reset my character just to see the new update.

Here is what i've tried:

while wait(3) do 
local ds = game:GetService("DataStoreService"):GetDataStore("InfectedPlaylistCount")
ds:UpdateAsync("val", function(Value)
script.Parent.Text = tostring(Value.." in playlist")
end)
end

I've tried making "ds" local, but no luck. The script gives me a value, but only gives me 1 value and then that's it, i'd have to reset to see an updated version.

Help would be appreciated.

1 answer

ds:UpdateAsync("val", function(Value), you forgot a closing bracket here.

Now for my suggestion:

Try using GetAsync to compare the values yourself, either indivisdually or by using a for loop.

1 comment

0

Tried GetAsync before above script, did not work. And I get what you mean by a for loop, but I don't get how for's come into this?

This discussion is preserved as it was. New answers, comments, and votes are closed.