ReserveServer / TeleportToPrivateServer how do I teleport?

Hi!

Yeah, I’m probably not thinking right, but how do I teleport? I’m having an issue with the placeId. In this code I kinda took from another post, and it said to replace the game.PlaceId to the ID of the game I’m trying to teleport to. Instead I just created a variable.

The error code says HTTP 403 (Forbidden) at local serverCode = teleportService:ReserveServer(PlaceId) in the CountDown function. It does start the countdown, but I’ve tried this in game and out of studio, and the teleport doesn’t work. Here’s the code:

local seats = workspace.Seats

local teleportService = game:GetService("TeleportService")

local num = 0

local playersInSeats = {}

local countdown = false

local PlaceId = 5239966475

local function countDown()
	
	if not countdown then 
	
		countdown = true
		
		print("Start countdown")
		playersInSeats = {}
		
		for i = 10,1,-1 do --first number changes countdown
			
			if num < 1 then break end -- if everyone gets off, reset timer
			if num == #seats:GetChildren() then break end -- if seats are full, teleport
			wait(1)
			
		end
		
		if num >= 1 then -- changes minimum number of players
			
			print("Start game")
			
			local serverCode = teleportService:ReserveServer(PlaceId) -- change game.PlaceId to the place id
			
			for _,seat in pairs(seats:GetChildren()) do
				
				if seat.Occupant then
					
					local plr = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent) -- occupant is the humanoid, hence why
					
					table.insert(playersInSeats,plr)
					
				end
				
			end
			
			for _,plr in pairs(playersInSeats) do 
				
				print(plr)
				
			end
			
			teleportService:TeleportToPrivateServer(PlaceId,serverCode,game.Players:GetPlayers()) -- change game.PlaceId to the place id, was playersInSeats
			
			countdown = false
			
		else
			
			countdown = false
			
		end
	
	end
	
end

for _,seat in pairs(seats:GetChildren()) do
	
	if seat:IsA("Seat") then
		
		seat:GetPropertyChangedSignal("Occupant"):connect(function()
			
			if seat.Occupant ~= nil then
				
				num = num + 1
				countDown()
				
			else
				
				num = num - 1
				
			end
			
		end)
		
	end
	
end

I’m not sure how to fix this and actually make the teleport work. Any help is greatly appreciated, thanks in advance!

1 Like

That error probably means the place you’re trying to teleport to isn’t in the same universe as the game you’re running this script in. You can’t reserve a private server in a place you don’t own. (Also, keep in mind you can’t test teleporting in Studio. I’d recommend testing in-game otherwise it’ll error.)

2 Likes

Screenshot (36)

I am teleporting from Crazy Killer to Crazy Killer - In Game
And I have been testing in both studio to find the errors and publishing and playing the game on roblox.

Okay, I guess the problem is that you’re testing this in Studio then. I didn’t realize that was the error for when you can’t reserve servers in Studio, oh well. Try doing it in-game and use the developer console (F9) to see if the errors are different there.

2 Likes

No she already said she had tested it in game.

Oh, I used the devoloper console, and I forgot to allow http services.

Yes, but there could be a different error since she said she only checked for errors in studio.

2 Likes

“Occupant is not a valid member of Script.” then I get the same error with the PlaceId in the CountDown.

Do you have a script in workspace.Seats? It seems like when you loop through seats at the bottom, it’s finding a script. Doing script:GetPropertyChangedSignal("Occupant") would probably throw that error.

2 Likes

Script is in seats, and I just tried that and I’m still getting the same error message.

Just tried what? I didn’t suggest a solution, just mentioned what the problem was.

2 Likes

script:GetPropertyChangedSignal(“Occupant”)

I’ve used this feature before and had some issues. This may help depending on your issue: TeleportToPrivateServer error!

That’s what I said would cause the error. An actual fix would be checking IsA VehicleSeat or whatever before trying to be the occupancy changed signal, so that it doesn’t try it on the script in there. A script can’t have an Occupant.

2 Likes

Oh, I needed to put the script in ServerScriptService. :sweat_smile: Thanks for all your help with this, I really appreciate it!

Huh, I’ve been experimenting with this because it is teleporting everyone in the server, not just those who are in the seats. When I specify who I’m teleporting I did seats:GetChildren() though it is still teleporting the whole server. Is there a way to say teleport those who on the seats?