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

I'm having issues with data store?

Asked by 9 years ago

Here's the script: It always attempts to load but says there isn't anything there, im sure the problem is at the green dashed line.

DataStore = game:GetService("DataStoreService"):GetDataStore("BSI")
Players = game:GetService("Players")

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

local Kills = Instance.new("IntValue", leader)
    Kills.Name = "Kills"

    local key = "user "..player.userId
    local Saved = DataStore:GetAsync(key)
    print (Saved[1])
    Kills.Value = Saved[1] or 0
    DataStore:SetAsync(key, Saved[1])
    print (key, Saved[1])
end)

game.Players.PlayerRemoving:connect(function(player)
    local key = "user "..player.userId
    print (key.." left")
    local ToSave = player.leaderstats.Kills.Value
    print (ToSave.." value")
    DataStore:SetAsync(key, 1 == ToSave) -----------------------
    print (key, ToSave)
    print 'SAVED'
end)
0
Why are you trying to save a condition as a value, why not just use the ToSave variable? Spongocardo 1991 — 9y
0
Are you trying to save the true or false condition? yumtaste 476 — 9y

1 answer

Log in to vote
0
Answered by
yumtaste 476 Moderation Voter
9 years ago

If you're trying to save a condition, then on line 22, it has to be "ToSave == 1." This is because the computer thinks like "this value is this number," not "this number is this value."

0
The order that line 22 was in was correct for what I was trying to do, it just doesn't work for this all together, "1" was the index of a table, not the value BSIncorporated 640 — 9y
Ad

Answer this question