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)
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)