Ultimate Boxing’s code system is currently broken due to this bug because I rely on OnUpdate registering when I update a DataStore key. The bug that is going on is that OnUpdate isn’t being fired when a key is updated in a different server, including Studio.
Steps to use the repo code:
Upload a place with the repro code to a game and make sure the studio API is enabled for DataStores.
Have a client open up the game, and run an instance in studio.
In the command line on either side, output a warning. You should see it echoed as a print statement. Ex: If you do warn(“Test”), you should see “Warned somewhere: Test”
Go to the other client. The message will not be echoed. Run the command warn(“RESYNC”), which will do a GetAsync on the key. OnUpdate will then be fired.
Code:
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("CrossServerPrint")
DataStore:OnUpdate("PrintMessage",function(NewValue)
if NewValue then
print("Warned somewhere: "..tostring(NewValue))
end
end)
game:GetService("LogService").MessageOut:Connect(function(Message,MessageType)
if MessageType == Enum.MessageType.MessageWarning then
if Message == "RESYNC" then
DataStore:GetAsync("PrintMessage")
else
DataStore:SetAsync("PrintMessage",Message)
end
end
end)
I am not sure how long this has been a bug. Ultimate Boxing only reached 500 concurrent players today, and I had several confirmed cases on Twitter for the code I put out today (1, 2, 3, 4, 5).
This is still a bug, can reproduce. Incredibly annoying, I’m trying to make a global announcement system and since OnUpdate doesn’t fire cross-servers, I’m using a work around with :GetAsync() on a loop. ):
Deprecating it wouldn’t be ideal. Some users may want it to fire even if it is changed to the same value it already was, but you won’t be able to tell if it was changed using GetAsync.
Really? What’s even the point in it then? We can just use bindable events. If there are no plans to change that behavior, then yeah just deprecate it regardless of this bug.
This bug almost completely nullifies the purpose of OnUpdate. Data in DataStores is supposed to be cross-server, available to the whole game. If I just wanted a method that tracks the cache, I could very well just write my own non-saving data mechanisms.
I know I was using OnUpdate a while ago and was relying on it for my matchmaking system (which my whole game was based around). Looks like nobody’s tagged a staff member so I’ll tag @Tiffblocks since this is a fairly big bug and if they’d have seen it I’m sure they would have said something.
OnUpdate polls once every 60 seconds for any watched keys that may be set by other game servers. For any updates that are made by the local game server, OnUpdate will pick up on those changes immediately.
This part of the process still isn’t working. I tried the example code in my test place (1 live server and 1 studio instance), and gave it about 5 minutes. The other server never got updated until I called GetAsync.
Probably should mention it has been 6 months since this bug was posted and it still isn’t fixed. Really bad for developers who want to use this functionality but don’t know the workaround to get it working.
Thanks for bumping this, I’ll see about prioritizing it.
Note: this may not be a priority given that cross server messaging is a solution designed specifically for this, and we may end up deprecating OnUpdate. We will see.
Any updates on this? I know the messaging system is getting close to being live, but there are still use cases for OnUpdate (ex: Setting promotion codes in 1 server and updating the test).
please consider fixing this, I’m using OnUpdate to allow players to buy items from each other across servers
If the player is in another server I want the player to receive the money instantly, but if he is offline then I want it to be stored in the datastore so the player can add the money to his account when he joins back
I’m using IncrementAsync+OnUpdate right now, but if I were to use MessagingService I would have to use IncrementAsync+MessagingService pub+MessagingService sub (and since messagingservice also has a dreadfully low budget I’d probably have to check if the player is playing the game with GetPlayerPlaceInstanceAsync)