How Can i make items in your inventory carry across servers

I want to know a script that makes items in your inventory carry acrross servers

4 Likes

What do you mean by this? Like on leave and join? Just use a Datastore and save it on leave, load it on join

6 Likes

yeah so like if i leave the game i want my items to save

2 Likes

Did you click on @OfficialPogCat’s link to read the documentation?
If you save items to Datastores for each player then you can have them available in their inventories when they rejoin.

1 Like

Use a datastore (like said) to save the objects. This is a basic example, I would recommend modifying it:

local function encodeInventory(TableOfInventory)
    -- Adds every inventory item's name into a string
    local encoding = ""

    for _, inventoryItem in TableOfInventory do
        encoding = encoding..","..inventoryItem.Name
    end

    return encoding
end

local function decodeInventory(encoding)
    -- Returns the name of every inventory item saved
    return string.split(encoding, ",")
end

Save the string returned from encodeInventory(inventory) to a DataStore. When the player loads back into the game, give every item listed from decodeInventory(encoding) into the player’s inventory:

for _, item in decodeInventory(encoding) do
    local item = game.ReplicatedStorage:WaitForChild("your items folder"):FindFirstChild(item)
    item:Clone().Parent = player.Backpack
end

Make sure to hook up your items folder to whatever folder keeps all your inventory items.

1 Like

im pretty new to scripting anybody mind telling me how to make and where to put the data store