Code issues - Place ID is not working

Hello, I would like to know what is wrong in the code of this script, I have put the id of this map “6294930493” and when the voting ends and the chosen map is heavenly, it does not load my map, what is wrong?

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 = 6294930493 -- ERROR HERE PLACE ID IS NOT WORKING
	local placeID_2 = 6055167339
	local placeID_3 = 6055233931
	
	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)
				
				if 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)
						
						if 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
			end
			
		end
			
		
	end
	
	
end

Do you have any errors? or results from the pcall?

I don’t get any error on the console, I don’t know what’s wrong :frowning:

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

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