Code issues - Voting system and player

Hello! I have that voting system script and I need to make some improvements to it.
I have tried but not succeeded, how could I make the players be teleported to specific parts.
as I show below:

  1. I need to make sure that if map 1 is chosen then the players are teleported to the part called ‘teleHere1’.

  2. I need to make sure that if map 2 is chosen then the players are teleported to the part called ‘teleHere2’.

  3. I need to make sure that if map 3 is chosen then the players are teleported to the part called ‘teleHere3’.

Does anyone know how to script that? :frowning:

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 = 6178579076
	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

Could you try to do this yourself first, maybe? This category isn’t for others to write code for you. If you just need help on what to do, then teleporting a player is as simple as CFraming their HumanoidRootPart to a desired position. You can use that as reference and then make an attempt yourself to code this.

As I know you need to use MoveTo
You can read an article about it here Model | Documentation - Roblox Creator Hub.

1 Like

It will teloport you to the part.

1 Like

I put the id of my “place” and it is not teleported :frowning:

Oh you want to make so it will telepor to other place?
I found a video for you

1 Like

thanks you bro :scream: :scream: