So I’m trying to do an inventory system with summoning like All Star Tower Defense,
I’ve made it so it saves the characters you get but I don’t know how I would do it so it
creates a NumberValue and gives the value of exp it had when it saved.
I’ve looked for any solutions, haven’t found any.
So what I thought could work is to make a table where it stores the character’s name and the exp so when you join it knows where to add the exp.
So I would have to do, not full code, I’m just imagining this is it.
local toSave
game.Players.PlayerAdded:Connect(function(plr)
local key = "id_"..plr.UserId
local GetSaved = ds:GetAsync(key)
if GetSaved then
toSave =? or something like that?
else
print("New User")
end
end)
local Data = {}
for i, Character in pairs(Inventory:GetChildren()) do
table.insert(Data, {
Name = Character.Name,
XP = Character.XP.Value
})
end
The data table would look like this
{
{
Name = "Goku",
XP = 125235
},
{
Name = "Mori Jin",
XP = 1252531
},
{
Name = "Mori Jin",
XP = 125235
},
{
Name = "Saitama",
XP = 125253235
},
{
Name = "Vegeta",
XP = 1255
},
}
So I did it and it works but it only loads 1 character.
So I’ve done the loading in for loops but it only does the last character in the array
I tried adding more for loops but nothing
Nevermind I fixed it I didn’t know why it didn’t work but I took a break to the bathroom and puff and an idea popped into my mind. I re-did the code and it works, the only thing left is to make it so it saves the exp because currently, it doesn’t save it.
Thank you so much I should have thought about arrays.
I sent a friend request on dc so we can talk more anyway thanks!