In my game script of my minigame, the players should go to the map which is chosen randomly, however when I test the game it says "Teleporting Players" however the players aren't being teleported. Is there and error on my gamescript?

My GameScript:

local maps = game.ServerStorage:WaitForChild("Maps"):GetChildren()
local lobby = game.Workspace:WaitForChild("Lobby")
local message = game.Workspace:WaitForChild("Message")
local numplayers = game.Workspace:WaitForChild("NumPlayers")
local chosenmap= game.Workspace:WaitForChild("ChosenMap")
local selected = game.Workspace:WaitForChild("SelectedMap")
local timer = game.Workspace:WaitForChild("Timer")
local playerNeeded = 1 -- for testing :P
local winners = {}
function deleteLastMap()
    selected:ClearAllChildren()
end
 
function checkPlayers()
    if numplayers.Value >= playerNeeded then
        return true
    else
        return false
    end
end
 
function getAlivePlayers()
    local n = 0
    local players = game.Players:GetPlayers()
    for i = 1,#players do
        if players[i].Settings.AFK.Value ~= false then
            if players[i].Character ~= nil then
                if players[i].Character.Humanoid.Health ~= 0 then
                    if players[i].Settings.Playing.Value ~= false then
                        n = n + 1
                    end
                end
            end
        end
    end
    return n
end
 
function getWinners()
    local n = 0
    local players = game.Players:GetPlayers()
    for i = 1,#players do
        if players[i].Settings.AFK.Value ~= false then
            if players[i].Character ~= nil then
                if players[i].Character.Humanoid.Health ~= 0 then
                    if players[i].Settings.Winners.Value ~= false then
                        n = n + 1
                    end
                end
            end
        end
    end
    return n
end
 
function intermission()
    for i = 5,1,-1 do -- 5 is the time
        wait(1)
        message.Value = "Intermission: "..i.." seconds!"
    end
end
 
function choosemap()
    message.Value = "Choosing map..."
    for i=1,#maps do
	if maps[i]:isA("Model")then
	chosenmap.Value = maps[math.random(1,#maps)].Name
end
end
end
 
function displayChosen()
    message.Value = "Map Chosen: "..chosenmap.Value.."!"
end
 
function loadMinigame()
    message.Value = "Loading map..."
    local clone = game:GetService("ServerStorage").Maps:FindFirstChild(chosenmap.Value)
    clone:Clone().Parent = selected
end
 
function startGame()
	local mapSpawn = selected:FindFirstChild(chosenmap.Value).Spawns:GetChildren()
	local lobbySpawn = game.Workspace.Lobby:GetChildren()
	local players = game.Players:GetPlayers()
	
	message.Value = "Teleporting Players..."
	wait(1)
	
	
	for i = 1,#players do
		if players[i] ~= nil then
			if players [1].Settings.AFK.Value~=false then
				if players[i].Character ~= false then
					if players[i].Character.Humanoid.Health~=0 then
						local ransp =mapSpawn[math.random(1,#mapSpawn)].CFrame + Vector3.new(0,3,0)
						players[i].Character.HumanoidRootPart.CFrame = ransp
						wait()
						if players[i] ~= nil then
 if players[i].Character ~= nil then
  players[i].Character.HumanoidRootPart.CFrame = ransp

						
					end
						end
						if players[i] ~= nil then
                        if players[i].Character ~= nil then
                        players[i].Character.HumanoidRootPart.CFrame = ransp
                        end
						end
					end
				end
			end
		end
	end
	
						
			
				
		
	
	wait(2)
	for i = 3,1,-1 do 
		wait(1)
		message.Value ="The game will start in"..i.."seconds!"
	end
	wait(1)
	message.Value = "Go!"
	for i = 1,#players do
		if players[i] ~= nil then
			if players[i].Settings.AFK.Value ~=true then
				if players[i].Character ~=nil then
					players[i].Settings.Playing.Value=true
					
				end
			end
		end
	end
	timer.Value = selected:FindFirstChild(chosenmap.Value).Timer.Value
	while timer.Value ~= 0 and getAlivePlayers()~=0 do
		wait(1)
		message.Value = "Time left:"..i.."seconds!"
		timer.Value = timer.Value-1
	end
	wait(1)
	message.Value="Time's up!"
	wait(2)
	for i,v in pairs(players) do
		if v.Settings.Winner.Value ==true then
			table.insert(winners.players[i])
			if #winners == 1 then
				message.Value = v.Name.."survived!"
				wait(2)
				message.Value="The winner will receive 50 credits!"
				v.leaderstats.Wins.Value=v.leaderstats.Wins.Value + 1
				v.leaderstats.Credits.Value=v.leaderstats.Credits.Value + 50
				
				
				elseif#winners>=2 then
				message.Value = "Many players have survived"
				wait(2)
				message.Value= "Each player will receive 25 credits!"
				v.Settings.Winner.Value=false
				v.leaderstats.Wins.Value=v.leaderstats.Wins.Value + 1
				v.leaderstats.Credits.Value=v.leaderstats.Credits.Value + 25
				 
				
			end
			
		end
	end
	wait(2)
	for i = 1,#players do
		if players[i]~=nil then
			if players[i].Character ~= nil then
				local ransp=lobbySpawn[math.random(1,#lobbySpawn)].CFrame+Vector3.new(0,3,0)
                players[i].Character.HumanoidRootPart.CFrame = ransp

		end
			
		end
	end
	end

 
while true do
    wait()
    if checkPlayers() then
        intermission()
        wait(1)
        choosemap()
        wait(3)
        displayChosen()
        wait(2)
        loadMinigame()
        wait(2)
        if checkPlayers()then
	    startGame()
end
  table.remove(winners)  
  deleteLastMap()


    end
end

Teleporting script in game script:

function startGame()
	local mapSpawn = selected:FindFirstChild(chosenmap.Value).Spawns:GetChildren()
	local lobbySpawn = game.Workspace.Lobby:GetChildren()
	local players = game.Players:GetPlayers()
	
	message.Value = "Teleporting Players..."
	wait(1)
	
	
	for i = 1,#players do
		if players[i] ~= nil then
			if players [1].Settings.AFK.Value~=false then
				if players[i].Character ~= false then
					if players[i].Character.Humanoid.Health~=0 then
						local ransp =mapSpawn[math.random(1,#mapSpawn)].CFrame + Vector3.new(0,3,0)
						players[i].Character.HumanoidRootPart.CFrame = ransp
						wait()
						if players[i] ~= nil then
 if players[i].Character ~= nil then
  players[i].Character.HumanoidRootPart.CFrame = ransp

						
					end
						end
						if players[i] ~= nil then
                        if players[i].Character ~= nil then
                        players[i].Character.HumanoidRootPart.CFrame = ransp
                        end
						end
					end
				end
			end
		end
	end

Are there any errors in the code which is stopping my player from teleporting. When I tested the game everything worked, just that the players didn't teleport to the map which was cloned/

Thank You and Help is appreciated

11 comments

0

Line 12 of the bottom script has Players[1] instead of [i]

0

still not teleporting?

0

First of all, we should be asking YOU if there are any errors. Also, no one will read 215 lines of code. Show relevant parts.

0

i did

0

the teleportation script

0

it says playing is not a valid member of folder on line 29 idk how to fix it

0

That means you havent created an instance with the name Playing in your Settings folder.

0

also, is this a free model?

0

What do you mean free model

0

as in a free model minigame script

0

no