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

Data saving combines stats?

Asked by
8jxms 9
4 years ago

I am using a data saving script and for the most part it works. What I am trying to do is save a players rebirths and strength. But when I rejoin the rebirth value is the same as the strength value (ex I have 50 strength 2 rebirths when I rejoin I have 50 strength 50 rebirths). Please help, here is the (server)script. Also btw this code is part of one big script that happens when the player joins the game.

    local strengthData, rebirthsData

    local success,errormessage = pcall(function()
        strengthData = DataStore:GetAsync("strength-"..player.UserId)
        rebirthsData = DataStore:GetAsync("rebirths-"..player.UserId)
    end)

    if success then
        if strengthData then
            strength.Value = strengthData
        end
        if rebirthsData then
            rebirths.Value = rebirthsData
        end
    end
end)


game.Players.PlayerRemoving:Connect(function(player)
    local success, errormessage = pcall(function()
        DataStore:SetAsync("strength-"..player.UserId,player.leaderstats.Strength.Value)
        DataStore:SetAsync("rebirths-"..player.UserId,player.leaderstats.Strength.Value)
    end)
end)

1 answer

Log in to vote
0
Answered by
NotedAPI 810 Moderation Voter
4 years ago
Edited 4 years ago

game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() DataStore:SetAsync("strength-"..player.UserId,player.leaderstats.Strength.Value) DataStore:SetAsync("rebirths-"..player.UserId,player.leaderstats.Strength.Value) end) end)

You put player.UserId,player.leaderstats.Strength.Value twice.

It should be something like this


game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() DataStore:SetAsync("strength-"..player.UserId,player.leaderstats.Strength.Value) DataStore:SetAsync("rebirths-"..player.UserId,player.leaderstats.Rebirths.Value) end) end)
0
this is the exact thing that I already have... 8jxms 9 — 4y
0
No it isn't. NotedAPI 810 — 4y
0
The first script is what you have, the second one isn't. NotedAPI 810 — 4y
0
You set the rebirths data as the strength. If you skim over it you can see you did Strength.Value for both DataStores NotedAPI 810 — 4y
View all comments (9 more)
0
i copied it in and nothing changed 8jxms 9 — 4y
0
Did you add to your rebirths? Because if you didn't that's why it stayed at 50 since you saved it as 50 which was your strength last time. NotedAPI 810 — 4y
0
no it didn't help it's still doing it 8jxms 9 — 4y
0
i tested it added to my strength rejoined rebirths are the same amount 8jxms 9 — 4y
0
Add to your rebirths. NotedAPI 810 — 4y
0
okay.. 8jxms 9 — 4y
0
Nope still not working 8jxms 9 — 4y
0
Is there any error? NotedAPI 810 — 4y
0
nope 8jxms 9 — 4y
Ad

Answer this question