Hey there!
I have just added a couple more data sets to my LONG list of data I need to save. I have noticed though, that the last three I added are not actually saving… I checked and made sure those three looked the same as all the others, and I can’t find anything. Then I thought it might be the fact that there is a ton of data that needs to be saved.
This is the way I did my datastore
function onPlayerEntered(player)
--Create a key to store player stats
local initKey = "user_" .. player.userId .. "_init"
local stepsKey = "user_" .. player.userId .. "_steps"
local pointsKey = "user_" .. player.userId .. "_points"
local speedKey = "user_" .. player.userId .. "_speed"
local trailKey = "user_" .. player.userId .. "_trail"
local animKey = "user_" .. player.userId .. "_anim"
local petKey = "user_" .. player.userId .. "_pet"
local xpKey = "user_" .. player.userId .. "_xp"
local levelKey = "user_" .. player.userId .. "_level"
local orbsBadgeKey = "user_" .. player.userId .. "_orbsBadge"
local winsBadgeKey = "user_" .. player.userId .. "_winsBadge"
local particleKey = "user_" .. player.userId .. "_particle"
local boughtKey = "user_" .. player.userId .. "_bought"
local rebirthKey = "user_" .. player.userId .. "_rebirth"
local placeKey = "user_" .. player.userId .. "_place"
local PUAKey = "user_" .. player.userId .. "_PUAKey"
local PUTKey = "user_" .. player.userId .. "_PUTKey"
local snackKey = "user_" .. player.userId .. "_snackKey"
--Creates default stats for new players
if(datastore:GetAsync(initKey) == nil) then
datastore:SetAsync(initKey, true)
datastore:SetAsync(stepsKey, 0)
datastore:SetAsync(pointsKey, 0)
datastore:SetAsync(speedKey, 1)
datastore:SetAsync(trailKey, "DefaultTrail")
datastore:SetAsync(animKey, "DefaultAnim")
datastore:SetAsync(petKey, "DefaultPet")
datastore:SetAsync(xpKey, 0)
datastore:SetAsync(levelKey, 1)
datastore:SetAsync(orbsBadgeKey, 0)
datastore:SetAsync(winsBadgeKey, 0)
datastore:SetAsync(particleKey, "DefaultParticleTrail")
datastore:SetAsync(boughtKey, {})
datastore:SetAsync(rebirthKey, 0)
datastore:SetAsync(placeKey, "Park")
datastore:SetAsync(PUAKey, {})
datastore:SetAsync(PUTKey, {})
datastore:SetAsync(snackKey, 0)
end
local init = datastore:GetAsync(initKey)
local steps = datastore:GetAsync(stepsKey)
local points = datastore:GetAsync(pointsKey)
local speed = datastore:GetAsync(speedKey)
local trail = datastore:GetAsync(trailKey)
local anim = datastore:GetAsync(animKey)
local pet = datastore:GetAsync(petKey)
local xp = datastore:GetAsync(xpKey)
local level = datastore:GetAsync(levelKey)
local orbsBadge = datastore:GetAsync(orbsBadgeKey)
local winsBadge = datastore:GetAsync(winsBadgeKey)
local particle = datastore:GetAsync(particleKey)
local bought = datastore:GetAsync(boughtKey)
local rebirth = datastore:GetAsync(rebirthKey)
local place = datastore:GetAsync(placeKey)
local PUA = datastore:GetAsync(PUAKey)
local PUT = datastore:GetAsync(PUTKey)
local snack = datastore:GetAsync(snackKey)
_G.boughtArray[player.userId] = bought
_G.petUpgradeAmount[player.userId] = PUA
_G.petUpgradeTime[player.userId] = PUT
--[[
a lot of code to add the values from the datastore... example:
local stepsBoard = Instance.new("IntValue")
stepsBoard.Name = "Steps"
stepsBoard.Value = steps
stepsBoard.Parent = player
]]--
end
Then I have the code when the player leaves…
function onPlayerLeaving(player)
local userId = player.UserId
local steps = player.Steps.Value
local speed = player.Speed.Value
local points = player.Points.Value
local trail = player.PlayerTrail.Value
local anim = player.PlayerAnim.Value
local pet = player.PlayerPet.Value
local xp = player.XP.Value
local level = player.Level.Value
local orbsBadge = player.OrbsBadgeCount.Value
local winsBadge = player.WinsBadgeCount.Value
local particle = player.PlayerParticleTrail.Value
local bought = _G.boughtArray[player.userId]
local rebirth = player.Rebirths.Value
local place = player.PlayerPlace.Value
local PUA = _G.petUpgradeAmount[player.userId]
local PUT = _G.petUpgradeTime[player.userId]
local snack = player.SwiftSnacks.Value
local stepsKey = "user_" .. player.userId .. "_steps"
local pointsKey = "user_" .. player.userId .. "_points"
local speedKey = "user_" .. player.userId .. "_speed"
local trailKey = "user_" .. player.userId .. "_trail"
local animKey = "user_" .. player.userId .. "_anim"
local petKey = "user_" .. player.userId .. "_pet"
local xpKey = "user_" .. player.userId .. "_xp"
local levelKey = "user_" .. player.userId .. "_level"
local orbsBadgeKey = "user_" .. player.userId .. "_orbsBadge"
local winsBadgeKey = "user_" .. player.userId .. "_winsBadge"
local particleKey = "user_" .. player.userId .. "_particle"
local boughtKey = "user_" .. player.userId .. "_bought"
local rebirthKey = "user_" .. player.userId .. "_rebirth"
local placeKey = "user_" .. player.userId .. "_place"
local PUAKey = "user_" .. player.userId .. "_PUA"
local PUTKey = "user_" .. player.userId .. "_PUT"
local snackKey = "user_" .. player.userId .. "_snack"
datastore:SetAsync(stepsKey, steps)
datastore:SetAsync(pointsKey, points)
datastore:SetAsync(speedKey, speed)
datastore:SetAsync(trailKey, trail)
datastore:SetAsync(animKey, anim)
datastore:SetAsync(petKey, pet)
datastore:SetAsync(xpKey, xp)
datastore:SetAsync(levelKey, level)
datastore:SetAsync(orbsBadgeKey, orbsBadge)
datastore:SetAsync(winsBadgeKey, winsBadge)
datastore:SetAsync(particleKey, particle)
datastore:SetAsync(boughtKey, bought)
datastore:SetAsync(rebirthKey, rebirth)
datastore:SetAsync(placeKey, place)
datastore:SetAsync(PUAKey, PUA)
datastore:SetAsync(PUTKey, PUT)
datastore:SetAsync(snackKey, snack)
end
game.Players.PlayerRemoving:Connect(onPlayerLeaving)
So, the last three aren’t saving, so maybe a solution(unless you see a typo or easily see the answer) would be to bunch all those values so I only have to Set:Async like only once or twice, like in a table or something? How would I do that?