Hello, I am having an error saying '1 is not a valid member of player' on line 107 I am very confused, as I don't see the number one anywhere. Here is my script:
local timenow = time() script.start.Value = timenow local replicatedStorage = game.ReplicatedStorage local status = replicatedStorage:WaitForChild('MinigameStuff'):WaitForChild('Status') local maps = {replicatedStorage.Maps.Map1} print('There are ' .. #maps .. " maps") local timenoww = time() script.eend.Value = timenoww local relapsed = script.start.Value - script.eend.Value print('GameScript loaded in ' .. relapsed .. " seconds") script.start:Destroy() print('Removed value start') script.eend:Destroy() print('Removed value eend') local message = game.ReplicatedStorage:WaitForChild('MinigameStuff'):WaitForChild('Status') local numplayers = game.Workspace:WaitForChild('NumPlayers') local playersneeded = 1 --mininum amount of players needed to sytart the game local chosenmap = game.Workspace:WaitForChild("ChosenMap") local selected = game.Workspace:WaitForChild("SelectedMap") local timer = game.Workspace:WaitForChild('Timer') local winners = {} local function checkplayers() if numplayers.Value >= playersneeded then return true else return false end end local 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].Humanoid.Health ~= 0 then if players[i].Settings.Playing.Value ~=false then n = n+1 end end end end end return n end local 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].Humanoid.Health ~= 0 then if players[i].Settings.Playing.Value ~=false then if players[i].Settings.Winner.Value ~= true then n = n+1 end end end end end end return n end local function intermission() for i = 10,1,-1 do --10 is the time. wait(1) message.Value = "Intermission (" ..i.. ")" end end local function choosemap() message.Value = 'Choosing map..' chosenmap.Value = maps[math.random(1,#maps)].Name wait(2) end local function displayChosen() message.Value = game.ReplicatedStorage:WaitForChild("Maps"):WaitForChild(chosenmap.Value):WaitForChild("MapName").Value .. ' was chosen' end local function loadMinigame() message.Value = 'Loading..' local clone = game.ReplicatedStorage.Maps:WaitForChild(chosenmap.Value):Clone() clone.Parent = workspace end local function deletelastmap() selected:ClearAllChildren() end local function startgame() local mapSpawn = selected:FindFirstChild(chosenmap.Value) local lobbySpawn = game.Workspace.Lobby.Spawns:GetChildren() local players = game.Players:GetPlayers() message.Value = 'Teleporting players...' wait(1) for i = 1,#players do local player = players[i] if player[i] ~= nil then if player[i].Settings.AFK.Value == false then if player[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) player[i].Character.HumanoidRootPart.CFrame = ransp end end end end end wait(2) for i = 3,1, -1 do --3 is the time wait(1) message.Value = "Game starting in " ..i.. "!" end wait(1) message.Value = "Game started!" 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 wait(1) timer.Value = selected:FindFirstChild(chosenmap.Value).Timer.Value while timer.Value ~= 0 and getaliveplayers() ~= 0 do wait(1) message.Value = 'Time left: ' .. timer.Value timer.Value = timer.Value -1 end wait(1) message.Value = 'Times up!' wait(4) for i = 1,#players do if players[i].Settings.Winner.Value == true then table.insert(winners,players[i]) if #winners == 1 then players[i].leaderstats.Wins.Value = players[i].leaderstats.Wins.Value +1 message.Value = players[i].Name .. ' won the game!' wait(4) message.Value = 'Good job! You will be rewared some cash!' players[i].leaderstats.Cash.Value = players[i].leaderstats.Cash.Value + 40 end end end end while true do wait() if checkplayers() then intermission() wait(2) choosemap() displayChosen() wait(4) loadMinigame() wait(2) if checkplayers() then startgame() end else message.Value = 'Waiting for players..' end end
I am honestly confused, and I would like anyone to explain it to me. Anything would help. Thank you!
Edit: This script isn't done, so please don't point out any other errors unless they are or may be related to the problem
The thing is you already found the player. You don't need the [i] because it check if the player has the number i instead of checking if the player still exists