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

Why is this happening in my data storage currency script? Like the -= in between savedData and nil

Asked by 4 years ago
Edited 4 years ago

``local currencyName = "Coins"

local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStore")

game.Players.PlayerAdded:Connect(function(player)

local folder = Instance.new("Folder")

folder.Name = "leaderstats"

folder.Parent = player

local currency = Instance.new("IntValue")

currency.Name = currencyName

currency.Parent = folder


local ID = currencyName.."-"..player.UserId
local savedData = nil

pcall(function()
    local savedData = DataStore:GetAsync(ID)
end)

if savedData -= nil then
    currency.Value = savedData
else
    currency.Value = 10
    print("New")
end

end)

game.Players.PlayerRemoving:Connect(function(player)

local ID = currencyName.."-"..player.UserId

DataStore:SetAsync(ID, player.leaderstats[currencyName].Value)

end)

game:BindToClose(function()

for i, player in pairs(game.Players:GetPlayers())do
    if player then 
        player:Kick("this game is shutting down")
    end
end

wait(5)

end)

0
nice code blocks greatneil80 2647 — 4y
0
You put ~=, not -=. Tilde equal sign, not hyphen equal sign. Unhumanly 152 — 4y

Answer this question