How to save an instance variable between a place and it's start place?

So in my horror game I’m adding a system where you get cash for beating heists. The “heists” are in a separate place that uses a starter place to get to. You will be able to buy cosmetics from the shop in the lobby (start place). Problem is I have no idea how to do it. If y’all could help, that would be great!

You can use teleportData and GetJoinData():

For start place (where is your shop where you can buy something):

-- Server

local joinData = player:GetJoinData()
local teleportData = joinData.TeleportData

if teleportData and teleportData.Coins then -- for example i have coins
	print(player.Name.." rejoined lobby with "..teleportData.Coins.." coins!")
end

For you place which is not lobby:

-- Server

local function teleport(player) -- this is not all function just a part of it
	local placeId = 16703375701
	local options = Instance.new("TeleportOptions")
	
	options:SetTeleportData({
		["Coins"] = player.Gold.Value,
		["Wins"] = player.Wins.Value
	})
	safeTeleport(placeId, {player}, options)
end

Also you can read Player | Documentation - Roblox Creator Hub

1 Like

Found a youtube tutorial, but I’ll give ya the solution still! Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.