Teleport players to game in same universe?

i want to teleport players to a public server when the lives value is = to 1, not a reserved server like a private server. i want it to teleport the player to a second game within the same universe using a code like this but i dont know how to approach it

local LivesFld = game.ReplicatedStorage.LiveEvents
local Debounce = {}

LivesFld.DiedFired.OnServerEvent:Connect(function(Player)
	if Debounce[Player] then return end
	Debounce[Player] = true

	local Lives = Player:WaitForChild("SystemFolder"):WaitForChild("Lives")
	Lives.Value -= 1

	Player.CharacterAdded:Connect(function()
		if Lives.Value == 1 then
                                  --TP PLAYER TO PUBLIC SERVER WITHIN SAME UNIVERS
			spawn(function()
				
			end)
		end
	end)

	wait(.25)
	Debounce[Player] = nil
end)

1 Like

can’t you just use TeleportService:TeleportAsync() ?

1 Like

@minimathew645 Try This:-

https://developer.roblox.com/en-us/articles/Teleporting-Between-Places

how would i put that into my script?

this will probably work assuming you’re doing this in a serverscript.

local LivesFld = game.ReplicatedStorage.LiveEvents
local ts = game:GetService("TeleportService")
local placeid =
--put your place's id there ^
local Debounce = {}

LivesFld.DiedFired.OnServerEvent:Connect(function(Player)
	if Debounce[Player] then return end
	Debounce[Player] = true

	local Lives = Player:WaitForChild("SystemFolder"):WaitForChild("Lives")
	Lives.Value -= 1

	Player.CharacterAdded:Connect(function()
		if Lives.Value == 1 then
			spawn(function()
				ts:TeleportAsync(placeid,Debounce[Player])
			end)
		end
	end)

	wait(.25)
	Debounce[Player] = nil
end)
1 Like

it says “Argument 2 missing or nil” in the output.