Best way to Save if Player owns item?

Data stores allow for data persistence within a game. Using data stores, associate each player with a dictionary of items they own structured like so:

local playerItems = {
    Apple = true,
    Pineapple = true,
    Sword = true,
}
-- checking for item
if playerItems[itemName] then
    print("player has item")
end
-- giving item
playerItems[itemName] = true
-- removing item
playerItems[itemName] = nil

This allows for item ownership setting and getting with a constant time complexity and is, in general, easier to use and understand.

There are several resources that teach you how to use data stores:

10 Likes