Code issues - Place ID is not working

Hello there! First of all, the error isn’t coming from the places IDs. I may be wrong, but I think you forgot to use the elseif function.

Here’s what your script will do:

Whenever the function Teleport() is activated, the script will only check if the name of your map is Celestial by Xepharim. If it is the case, all players will get teleported to your map. However if it is not the case, the script will stop and won’t check for other maps.

Here’s how you can fix your script:

local function Teleport()
	if mapName == "Celestial by Xepharim" then
		local success, result = pcall(function()
			return TeleportService:TeleportPartyAsync(placeID_1, playerList)
		end)
		if success then
			local jobID = result
			print("Players teleported to " ..jobID)
		end
	elseif mapName == "Circuit Board" then
		local success, result = pcall(function()
			return TeleportService:TeleportPartyAsync(placeID_2, playerList)
		end)
		if success then
			local jobID = result
			print("Players teleported to " ..jobID)
		end
	elseif mapName == "The Oil Rig by PetitePYT" then
		local success, result = pcall(function()
			return TeleportService:TeleportPartyAsync(placeID_3, playerList)
		end)
		if success then
			local jobID = result
			print("Players teleported to " ..jobID)
		end
	end
end

:warning: Remember: You CANNOT use TeleportService in Studio!

1 Like