Yes, I did use a simulator tutorial script because I'm not good at services.
I'm trying to save a huge chunk of values and I used :GetChildren() and it doesn't work.
I'm trying to find an alternative way to save tons of values without putting tons of functions.
Here is the script:
local DS = game:GetService("DataStoreService"):GetDataStore("StatData")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = "id_"..plr.userId
local savevalue = plr.leaderstats.Coins
local savevalue2 = plr.leaderstats.Gems
local savevalue3 = plr.leaderstats.Power
local savevalue4 = plr.Stats.ElementInv:GetChildren()
local savevalue5 = plr.Stats.PetInv:GetChildren()
local GetSaved = DS:GetAsync(plrkey)
if GetSaved then
for e = 1,#savevalue4 do
for a = 1,#savevalue5 do
local save4 = savevalue4[e]
local save5 = savevalue5[a]
savevalue.Value = GetSaved[1]
savevalue2.Value = GetSaved[2]
savevalue3.Value = GetSaved[3]
save4.Value = GetSaved[4]
save5.Value = GetSaved[5]
end
end
else
for e = 1,#savevalue4 do
for a = 1,#savevalue5 do
local save4 = savevalue4[e]
local save5 = savevalue5[a]
local NumbersForSaving = {savevalue.Value, savevalue2.Value, savevalue3.Value, save4.Value, save5.Value}
DS:GetAsync(plrkey, NumbersForSaving)
end
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local savevalue = plr.leaderstats.Coins
local savevalue2 = plr.leaderstats.Gems
local savevalue3 = plr.leaderstats.Power
local savevalue4 = plr.Stats.ElementInv:GetChildren()
local savevalue5 = plr.Stats.PetInv:GetChildren()
for e = 1,#savevalue4 do
for a = 1,#savevalue5 do
local save4 = savevalue4[e]
local save5 = savevalue5[a]
DS:SetAsync("id_"..plr.userId, {savevalue.Value, savevalue2.Value, savevalue3.Value, save4.Value, save5.Value})
end
end
end)

17 comments
Roblox is down rn. I'll accept your answer if it works.
Roblox is now back up can you give me more information on where to insert the values and what some of the stuff is supposed to be please?
Another reminder to give me the instructions of the script.
Another reminder to give me the instructions of the script.
everything between the lines of 1 and 6 goes in the PlayerJoined function. everything below line 8 is for the PlayerLeaving function
The leaderstats isn't the problem it's the petinv and elementinv.
The leaderstats isn't the problem it's the petinv and elementinv.
Bruh why do my comments keep duplicating?
Wait I realized I could just put the elementinva and petinv inside the i v thing.
I need more information on how this works because it isn't functioning.
I need more information on how this works because it isn't functioning.
Data stores don't save on PlayerLeave if your in studio, have you tried testing it in the actual roblox game. Sorry fr the late response
I have and it doesn't seem to function. I'll try to figure this out on my own since the responses are not fast.
Ok when I try to save a bool value which is in PetInv and ElementInv it doesn't work because the save system can't do it for some reason.
Ok when I try to save a bool value which is in PetInv and ElementInv it doesn't work because the save system can't do it for some reason.
This site needs to fix comment duplication.
Ok I have set all the bool values into number values so 0 = false and 1 = true but the loading thing does not work. Could you give me more info on just that. Sorry for all the trouble.