Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I save inventory items? I have a script that saves leaderstats and I want to edit it in.

I need help saving inventory items. I can save the leader board, but not their inventory items. Here is the script I'm using, I want it to also save inventory items but idk how.

 function onPlayerEntered(player)
 wait(3)
 player:WaitForDataReady()
repeat wait() until player:FindFirstChild("leaderstats")
 if player.DataReady then
 if player:findFirstChild("leaderstats") then
 local score = player.leaderstats:GetChildren()
 for i = 1,#score do
 local ScoreLoaded = player:LoadNumber(score[i].Name)
 wait()
 if ScoreLoaded ~= 0 then
 score[i].Value = ScoreLoaded
 end
end
 end
 end
 end
 
 function onPlayerLeaving(player)
 if player:findFirstChild("leaderstats") then
 local score = player.leaderstats:GetChildren()
 for i = 1,#score do
player:SaveNumber(score[i].Name,score[i].Value)
end
end
end
 
game.Players.PlayerAdded:connect(onPlayerEntered)
 game.Players.PlayerRemoving:connect(onPlayerLeaving)

Thank For Help.

1 answer

You don't save the inventory items itself. How does the user obtain items? If its from a shop or something, use data store to save whether or not they have unlocked that item, and to give it to them when they join

This discussion is preserved as it was. New answers, comments, and votes are closed.