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

Can you do this with DataStore?

Asked by 10 years ago
local DataStore = game:GetService("DataStoreService"):GetDataStore("Time")

game.Players.PlayerRemoving:connect(function(player)
local label = player.PlayerGui.TimeLeft.Frame.TimeLeftLabel
local ready = player.PlayerGui.TimeLeft.Frame.Ready.ReadyToVisit
local key = "user_" .. player.userId    --we want to give 50 points to users each time they visit   

DataStore:UpdateAsync(key, function(oldValue)
local newValue = label.Value or oldValue or 30 --oldValue might be nil
return newValue
end) --datastore end
end)

I want to update the value when you leave, but I can't get an output and it doesn't seem to work. Help?

(Why do I keep on getting thumbs downs?)

Answer this question