'Game tools in player inventory being shown in game PLACE'

Basically, what I want to do is when a player receives a tool, I technically want to ‘save it’ in their inventory, and when they teleport to a PLACE, I want it so it shows up in their inventory. I have seen no solutions meaning this should be impossible but I don’t know. I don’t have any code with me right now as I have no clue like I said.

1 Like

Is this place you want to teleport to within the same universe as the starter place?

1 Like

Yeah! Basically the Starter Place is like a HUB and then if you go through some sort of teleportation thing it makes you go to a game place. (not another HUB or main game)

You can use a datastore to store this information then erase the data when the player receives the tool in the new place, or you can send teleportData with the TeleportService.

1 Like

Ah, never thought of that! Thanks so much, marking as the solution!

Do you have any examples like a script or so?

Be sure to trigger the functions.

Saving

local DataStoreService = game:GetService("DataStoreService")
local toolsStore = DataStoreService:GetDataStore("Tools")

function Teleport(Player)
    local Tools = {}
    for _,Tool in pairs(Player.Backpack:GetChildren()) do
        table.insert(Tools,Tool.Name)
    end
    local success, err = pcall(function()
	      toolsStore:SetAsync(Player.UserId, Tools)
    end)
    if success then
	      --Teleport Code Here
    end
end

Receiving

local DataStoreService = game:GetService("DataStoreService")
local toolsStore = DataStoreService:GetDataStore("Tools")

function GetTools(Player)
    local success, err = pcall(function()
	      Data = toolsStore:GetAsync(Player.UserId)
    end)
    if success then
	      for _,Tool in pairs(Data) do
            local Clone = LocationOfTools:FindFirstChild(Tool):Clone()
            Clone.Parent = --Backpack or StaterPlayerTools
        end
        toolsStore:RemoveAsync(Player.UserId)
    end
end
1 Like