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

Data store table issues?

Asked by 9 years ago

I'm trying to make this Data Store save a player's backpack, and load it when they come back, but nothing happens, nothing returns with printing, no errors in the output. (Ignore the Kills part, it works fine)

if player_store:GetAsync("Kills") then
    Kills.Value = player_store:GetAsync("Kills")
    else
    Kills.Value = 0
    end
    if player_store:GetAsync("Weapons") then
    for i,v in pairs (player.BackPack:GetChildren()) do
        v:remove()
    end
    local Weapons = player_store:GetAsync("Weapons")
    for i in Weapons do
        game.Lighting:FindFirstChild(i):Clone().Parent = player.BackPack
    end
    end
end)

game.Players.PlayerRemoving:connect(function(player)
    player_store = DataStore:GetDataStore(player.userId.."Z")
    if player_store:GetAsync("Kills") then
    player_store:SetAsync("Kills", player.leaderstats.Kills.Value)
    else
    player_store:SetAsync("Kills", player.leaderstats.Kills.Value)  
    end
    if player_store:GetAsync("Weapons") then
        print 'its here'
    local Weapons = {}
    for i,v in pairs (player.BackPack:GetChildren()) do
        Weapons[v] = v
    end
    player_store:SetAsync("Weapons", Weapons)
    else
    local Weapons = {}
    for i,v in pairs (player.BackPack:GetChildren()) do
        Weapons[v] = v
    end
    player_store:SetAsync("Weapons", Weapons)
    end
end)

game.Close:connect(function() wait (5) end)
0
I remember helping you with something like this a week or so ago :{ ImageLabel 1541 — 9y
0
Well now im trying to table within it, what you helped me with works BSIncorporated 640 — 9y

1 answer

Log in to vote
1
Answered by
ImageLabel 1541 Moderation Voter
9 years ago

You could simplify a lot of the code you've posted. I remember helping you with something like this here, refer to that for further information.

Question: how are you verifying that these saved stats are specific to players? What you have presented would update the data store Kills with the last player's Kill statistic, and your scripts would be based on that last player's stat, but will affect all players...

In other words, if one player works hard to achieve a high kill stat, player after him will ruin that achievement because their stat will basically replace his.

0
I just realized the script error had nothing to do with scripting. The weapon set that is saved is my old weapons and then the ones its trying to load are the new ones, which all have completely different names BSIncorporated 640 — 9y
Ad

Answer this question