Why is this happening in my data storage currency script? Like the -= in between savedData and nil
Asked by
5 years ago Edited 5 years ago
``local currencyName = "Coins"
local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStore")
game.Players.PlayerAdded:Connect(function(player)
01 | local folder = Instance.new( "Folder" ) |
03 | folder.Name = "leaderstats" |
07 | local currency = Instance.new( "IntValue" ) |
09 | currency.Name = currencyName |
11 | currency.Parent = folder |
14 | local ID = currencyName.. "-" ..player.UserId |
18 | local savedData = DataStore:GetAsync(ID) |
21 | if savedData - = nil then |
22 | currency.Value = savedData |
end)
game.Players.PlayerRemoving:Connect(function(player)
1 | local ID = currencyName.. "-" ..player.UserId |
3 | DataStore:SetAsync(ID, player.leaderstats [ currencyName ] .Value) |
end)
game:BindToClose(function()
1 | for i, player in pairs (game.Players:GetPlayers()) do |
3 | player:Kick( "this game is shutting down" ) |
end)