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

How can I select a huge amount of values when saving?

Asked by 4 years ago

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:

01local DS = game:GetService("DataStoreService"):GetDataStore("StatData")
02game.Players.PlayerAdded:Connect(function(plr)
03    wait()
04    local plrkey = "id_"..plr.userId
05    local savevalue = plr.leaderstats.Coins
06    local savevalue2 = plr.leaderstats.Gems
07    local savevalue3 = plr.leaderstats.Power
08    local savevalue4 = plr.Stats.ElementInv:GetChildren()
09    local savevalue5 = plr.Stats.PetInv:GetChildren()
10    local GetSaved = DS:GetAsync(plrkey)
11    if GetSaved then
12        for e = 1,#savevalue4 do
13            for a = 1,#savevalue5 do
14                local save4 = savevalue4[e]
15                local save5 = savevalue5[a]
View all 47 lines...

1 answer

Log in to vote
0
Answered by
NeptyU 15
4 years ago
01-- Saving
02local SaveTable = {}
03for i, v in pairs(plr.leaderstats:GetChildren()) do
04    table.insert(SaveTable,{v.Name..v.Value})
05end
06 
07-- Loading
08 
09for i, v in pairs(DS:GetAsync("id"..plr.userId)) do
10    if plr.leaderstats:FindFirstChild(v[1]) ~= nil then
11        plr.leaderstats[v[1]].Value = v[2]
12    end
13end

Might work im not sure, if it doesn't it kinda gives an idea on how to do it

0
Roblox is down rn. I'll accept your answer if it works. CandyWreckEpicness 115 — 4y
0
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? CandyWreckEpicness 115 — 4y
0
Another reminder to give me the instructions of the script. CandyWreckEpicness 115 — 4y
0
Another reminder to give me the instructions of the script. CandyWreckEpicness 115 — 4y
View all comments (13 more)
0
everything between the lines of 1 and 6 goes in the PlayerJoined function. everything below line 8 is for the PlayerLeaving function NeptyU 15 — 4y
0
The leaderstats isn't the problem it's the petinv and elementinv. CandyWreckEpicness 115 — 4y
0
The leaderstats isn't the problem it's the petinv and elementinv. CandyWreckEpicness 115 — 4y
0
Bruh why do my comments keep duplicating? CandyWreckEpicness 115 — 4y
0
Wait I realized I could just put the elementinva and petinv inside the i v thing. CandyWreckEpicness 115 — 4y
0
I need more information on how this works because it isn't functioning. CandyWreckEpicness 115 — 4y
0
I need more information on how this works because it isn't functioning. CandyWreckEpicness 115 — 4y
0
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 NeptyU 15 — 4y
0
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. CandyWreckEpicness 115 — 4y
0
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. CandyWreckEpicness 115 — 4y
0
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. CandyWreckEpicness 115 — 4y
0
This site needs to fix comment duplication. CandyWreckEpicness 115 — 4y
0
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. CandyWreckEpicness 115 — 4y
Ad

Answer this question