I am trying to make a script where it saves the number as you can see on the first line. I'm pretty sure this is the false way to do it but this is all the wiki gave me. I hope this is correct. Any help appreciated. This is a local script in a screen gui. The error is: 'DateStoreService' is not a valid Service name
local DataStore = game:GetService("DateStoreService"):GetDataStore(script.Parent.Number) game.Players.PlayerAdded:connect(function(player) local key = "user_".. player.userId DataStore:UpdateAsync(key, function(oldValue) local newValue = oldValue or 0 newValue = newValue + 10 return newValue end) end) game.Players.PlayerRemoving:connect(function(player) local key = "user_".. player.userId DataStore:UpdateAsync(key, function(oldValue) local newValue = oldValue return newValue end) end)
DataStores don't work from LocalScripts. For that matter, I don't think PlayerRemoving
or PlayerAdded
work in a LocalScript either.
Usually when you're using PlayerAdded
or PlayerRemoving
, it's a good hint you shouldn't be using a LocalScript, anyway.