Code issues - teleport does not work properly

Hello, the ‘teleport’ of my script does not work, it does not teleport the players and I do not know what is wrong.
it does not teleport the players to the map.

I’m testing it from my game: https://www.roblox.com/games/6317343768/Inv-s?refPageId=e05b12f4-c569-4110-a153-bc29d8a36055

I don’t know what I did wrong … but it doesn’t work, I’ll share a screenshot:

image
image
image

script:

local pads = script.Parent.MapVotePads

local mapBoards = script.Parent.MapBoards

local votingStatus = script.Parent.VotingStatus


local canVote = false


local maps = 
	{
		["The Oil Rig by PetitePYT"] = 1515986593,
		["Circuit Board"] = 177925016,
		["Celestial by Xepharim"] = 6234886669,

	}



while true do

	pads.MapVote1.Votes:ClearAllChildren()
	pads.MapVote2.Votes:ClearAllChildren()
	pads.MapVote3.Votes:ClearAllChildren()

	pads.MapVote1.VotedGui.VotedAmount.Text = ""
	pads.MapVote2.VotedGui.VotedAmount.Text = ""
	pads.MapVote3.VotedGui.VotedAmount.Text = ""

	mapBoards.Map1.MapGui.MapImage.ImageTransparency = 1
	mapBoards.Map2.MapGui.MapImage.ImageTransparency = 1
	mapBoards.Map3.MapGui.MapImage.ImageTransparency = 1

	mapBoards.Map1.MapGui.MapName.Text = ""
	mapBoards.Map2.MapGui.MapName.Text = ""
	mapBoards.Map3.MapGui.MapName.Text = ""

	for i = 10, 0, -1 do

		votingStatus.StatusGui.Status.Text = "Voting will begin in " .. i .. " seconds"

		wait(1)
	end


	votingStatus.StatusGui.Status.Text = "Vote for the map"



	local keysTable = {}
	for key, value in pairs(maps) do
		table.insert(keysTable, key)
	end

	local randomKey1 = keysTable[math.random(#keysTable)]
	local mapChosen1 = maps[randomKey1]

	local randomKey2, mapChosen2
	repeat
		randomKey2 = keysTable[math.random(#keysTable)]
		mapChosen2 = maps[randomKey2]
	until mapChosen2 ~= mapChosen1

	local randomKey3, mapChosen3
	repeat
		randomKey3 = keysTable[math.random(#keysTable)]
		mapChosen3 = maps[randomKey3]
	until mapChosen3 ~= mapChosen1 and mapChosen3 ~= mapChosen2


	mapBoards.Map1.MapGui.MapImage.ImageTransparency = 0
	mapBoards.Map2.MapGui.MapImage.ImageTransparency = 0
	mapBoards.Map3.MapGui.MapImage.ImageTransparency = 0

	mapBoards.Map1.MapGui.MapImage.Image = "rbxassetid://" .. mapChosen1
	mapBoards.Map2.MapGui.MapImage.Image = "rbxassetid://" .. mapChosen2
	mapBoards.Map3.MapGui.MapImage.Image = "rbxassetid://" .. mapChosen3

	mapBoards.Map1.MapGui.MapName.Text = randomKey1
	mapBoards.Map2.MapGui.MapName.Text = randomKey2
	mapBoards.Map3.MapGui.MapName.Text = randomKey3


	pads.MapVote1.VotedGui.VotedAmount.Text = "0"
	pads.MapVote2.VotedGui.VotedAmount.Text = "0"
	pads.MapVote3.VotedGui.VotedAmount.Text = "0"

	canVote = true


	local function onPadTouched(touch, pad)
		if not canVote then return end
		if game.Players:GetPlayerFromCharacter(touch.Parent) then

			if pads.MapVote1.Votes:FindFirstChild(game.Players:GetPlayerFromCharacter(touch.Parent).Name) then 
				pads.MapVote1.Votes[game.Players:GetPlayerFromCharacter(touch.Parent).Name]:Destroy()
			end
			if pads.MapVote2.Votes:FindFirstChild(game.Players:GetPlayerFromCharacter(touch.Parent).Name) then 
				pads.MapVote2.Votes[game.Players:GetPlayerFromCharacter(touch.Parent).Name]:Destroy()
			end
			if pads.MapVote3.Votes:FindFirstChild(game.Players:GetPlayerFromCharacter(touch.Parent).Name) then 
				pads.MapVote3.Votes[game.Players:GetPlayerFromCharacter(touch.Parent).Name]:Destroy()
			end

			local touchVal = Instance.new("StringValue")
			touchVal.Name = game.Players:GetPlayerFromCharacter(touch.Parent).Name
			touchVal.Parent = pad.Votes

			pads.MapVote1.VotedGui.VotedAmount.Text = #pads.MapVote1.Votes:GetChildren()
			pads.MapVote2.VotedGui.VotedAmount.Text = #pads.MapVote2.Votes:GetChildren()
			pads.MapVote3.VotedGui.VotedAmount.Text = #pads.MapVote3.Votes:GetChildren()
		end
	end

	pads.MapVote1.Touched:Connect(function(touch)
		onPadTouched(touch, pads.MapVote1)
	end)
	pads.MapVote2.Touched:Connect(function(touch)
		onPadTouched(touch, pads.MapVote2)
	end)
	pads.MapVote3.Touched:Connect(function(touch)
		onPadTouched(touch, pads.MapVote3)
	end)

	wait(20)

	for i = 10, 0, -1 do

		votingStatus.StatusGui.Status.Text = "There are " ..i.. " seconds left to vote" 

		wait(1)
	end


	canVote = false


	local highestVoted

	for i, pad in pairs(pads:GetChildren()) do

		if not highestVoted then highestVoted = pad end

		if #pad.Votes:GetChildren() > #highestVoted.Votes:GetChildren() then 

			highestVoted = pad

		elseif #pad.Votes:GetChildren() == #highestVoted.Votes:GetChildren() then 

			local mapsToChoose = {pad, highestVoted}
			highestVoted = mapsToChoose[math.random(#mapsToChoose)]
		end
	end

	local mapName = mapBoards["Map" .. string.gsub(highestVoted.Name, "MapVote", "")].MapGui.MapName.Text
	votingStatus.StatusGui.Status.Text = mapName .. " has been voted"

	wait(5)

	votingStatus.StatusGui.Status.Text = "Loading " .. mapName

	wait(10)

	local TeleportService = game:GetService("TeleportService")
	local Players = game:GetService("Players")

	local placeID_1 = 6322319510 -- IDS PASTE HERE 6322319510
	local placeID_2 = 6322319510 -- IDS PASTE HERE 6322319510
	local placeID_3 = 6322319510 -- IDS PASTE HERE 6322319510

	local playerList = Players:GetPlayers()
	
	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
end
1 Like

Maybe you were testing it on the studio?

Teleport service does not work on studio, but only on the roblox player.

1 Like

When I enter from the ‘roblox player’ it does not work either, and this message appears when I enter my game:

1 Like

It seems you’re trying to teleport to a place that you don’t own.

That or roblox is down (I don’t think so)

Should I configure something on the map?

Celestial by Xepharim MAP:
image

You’re game I’d is wrong I believe.

So you’re inputting an invalid place id as of now.
So check your place I’d again, that’s the error here.

1 Like

should i have the map published? public? and the api active? Is it just that or should I put add map on which map?

If it does not belong to the game, then you can go to the website, and add a place to the game. Then you can just teleport there. If it’s a place by someone else, then you can ask for permission for studio access, then duplicate the map into your game.(Do make sure to give credit of course)