Saving Player Avatar/Inventory while Teleporting Between Places

What do you want to achieve?
I would like the player’s inventory, hair, hat(s), accessories, face, shirt, and pants to be saved as they teleport to different Places within the Experience.

Here’s the scripts I’ve written so far; however, they’re not working :sweat_smile: I’m very new to scripting and have been researching TeleportData/Service for a while but it’s been a struggle.

Serverscript w/in proximity prompt/part in Orgin Game:
Screen Shot 2022-07-02 at 6.51.57 PM

local ProximityPrompt = script.Parent
local Place = --ID

local teleportData = {
	["HairAccessory"] = workspace.HumanoidDescription.HairAccessory,
	["Hair"] = workspace.HumanoidDescription.Hair,
	["Hat"] = workspace.HumanoidDescription.Hat,
	["Face"] = workspace.HumanoidDescription.Face,
	["Shirt"] = workspace.HumanoidDescription.Shirt
	["Pants"] = workspace.HumanoidDescription.Pants,
	["Inventory"] = workspace.Players.LocalPlayer.Backpack
}
	
	ProximityPrompt.Triggered:Connect(function(plr)
		TeleportService:Teleport(Place, plr, teleportData)
	end)

LocalScript w/in StarterPlayerScripts in Destination Game:

local TeleportService = game:GetService("TeleportService")
 local teleportData = TeleportService:GetLocalPlayerTeleportData()
 if teleportData then
humanoid_Description.Name = "HumanoidDescription"
humanoid_Description.Parent = game.Workspace
humanoid_Description.HairAccessory = data["HairAccessory"]
humanoid_Description.Face = data["Hair"]
humanoid_Description.Face = data["Hat"]
humanoid_Description.Face = data["Face"]
humanoid_Description.Shirt = data["Shirt"]
humanoid_Description.Face = data["Pants"]
humanoid_Description.Face = data["Inventory"]

plr:LoadCharacterWithHumanoidDescription(workspace.HumanoidDescription)
	end
end)

I’m sorry for my terrible scripts, I’m very new to scripting but truly enjoy using the DevForum as a resource for learning :slight_smile:

Thank you!

1 Like

documentation below
Teleporting Between Places (roblox.com)

script from the documentation

before being teleported

local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
 
local SafeTeleport = require(ServerScriptService.SafeTeleport)
local RNG = Random.new()
 
local playerToTeleport = Players:GetPlayers()[1] -- get the first player in the game
 
local teleportData = {
    randomNumber = RNG:NextInteger(1, 100);
}
 
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions:SetTeleportData(teleportData)
 
SafeTeleport(game.PlaceId, {playerToTeleport}, teleportOptions)

upon joining the new server

local Players = game:GetService("Players")
 
local function onPlayerAdded(player)
    local joinData = player:GetJoinData()
    local teleportData = joinData.TeleportData
    local randomNumber = teleportData.randomNumber
 
    print(player.Name .. "joined with the number" .. randomNumber)
end
 
Players.PlayerAdded:Connect(onPlayerAdded)

You can’t send instances through teleport data. What I would do instead is insert the keys into a table, then send that table. Then on the receiving server, read the table and from those keys, index and give the corresponding items to the player