1 Is not a valid member of Player error in my minigame script. Whats wrong?
Asked by
5 years ago Edited 5 years ago
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:
001 | local timenow = time() |
002 | script.start.Value = timenow |
003 | local replicatedStorage = game.ReplicatedStorage |
004 | local status = replicatedStorage:WaitForChild( 'MinigameStuff' ):WaitForChild( 'Status' ) |
005 | local maps = { replicatedStorage.Maps.Map 1 } |
006 | print ( 'There are ' .. #maps .. " maps" ) |
007 | local timenoww = time() |
008 | script.eend.Value = timenoww |
009 | local relapsed = script.start.Value - script.eend.Value |
010 | print ( 'GameScript loaded in ' .. relapsed .. " seconds" ) |
011 | script.start:Destroy() |
012 | print ( 'Removed value start' ) |
014 | print ( 'Removed value eend' ) |
015 | local message = game.ReplicatedStorage:WaitForChild( 'MinigameStuff' ):WaitForChild( 'Status' ) |
016 | local numplayers = game.Workspace:WaitForChild( 'NumPlayers' ) |
017 | local playersneeded = 1 |
018 | local chosenmap = game.Workspace:WaitForChild( "ChosenMap" ) |
019 | local selected = game.Workspace:WaitForChild( "SelectedMap" ) |
020 | local timer = game.Workspace:WaitForChild( 'Timer' ) |
023 | local function checkplayers() |
024 | if numplayers.Value > = playersneeded then |
031 | local function getaliveplayers() |
033 | local players = game.Players:GetPlayers() |
034 | for i = 1 ,#players do |
035 | if players [ i ] .Settings.AFK.Value = = false then |
036 | if players [ i ] .Character ~ = nil then |
037 | if players [ i ] .Humanoid.Health ~ = 0 then |
038 | if players [ i ] .Settings.Playing.Value ~ = false then |
049 | local function getwinners() |
051 | local players = game.Players:GetPlayers() |
052 | for i = 1 ,#players do |
053 | if players [ i ] .Settings.AFK.Value = = false then |
054 | if players [ i ] .Character ~ = nil then |
055 | if players [ i ] .Humanoid.Health ~ = 0 then |
056 | if players [ i ] .Settings.Playing.Value ~ = false then |
057 | if players [ i ] .Settings.Winner.Value ~ = true then |
068 | local function intermission() |
071 | message.Value = "Intermission (" ..i.. ")" |
076 | local function choosemap() |
077 | message.Value = 'Choosing map..' |
078 | chosenmap.Value = maps [ math.random( 1 ,#maps) ] .Name |
084 | local function displayChosen() |
085 | message.Value = game.ReplicatedStorage:WaitForChild( "Maps" ):WaitForChild(chosenmap.Value):WaitForChild( "MapName" ).Value .. ' was chosen' |
088 | local function loadMinigame() |
089 | message.Value = 'Loading..' |
090 | local clone = game.ReplicatedStorage.Maps:WaitForChild(chosenmap.Value):Clone() |
091 | clone.Parent = workspace |
095 | local function deletelastmap() |
096 | selected:ClearAllChildren() |
099 | local function startgame() |
100 | local mapSpawn = selected:FindFirstChild(chosenmap.Value) |
101 | local lobbySpawn = game.Workspace.Lobby.Spawns:GetChildren() |
102 | local players = game.Players:GetPlayers() |
103 | message.Value = 'Teleporting players...' |
105 | for i = 1 ,#players do |
106 | local player = players [ i ] |
107 | if player [ i ] ~ = nil then |
108 | if player [ i ] .Settings.AFK.Value = = false then |
109 | if player [ i ] .Character ~ = false then |
110 | if players [ i ] .Character.Humanoid.Health ~ = 0 then |
111 | local ransp = mapSpawn [ math.random( 1 ,#mapSpawn) ] .CFrame + Vector 3. new( 0 , 3 , 0 ) |
112 | player [ i ] .Character.HumanoidRootPart.CFrame = ransp |
122 | message.Value = "Game starting in " ..i.. "!" |
127 | message.Value = "Game started!" |
129 | if players [ i ] ~ = nil then |
130 | if players [ i ] .Settings.AFK.Value ~ = true then |
131 | if players [ i ] .Character ~ = nil then |
132 | players [ i ] .Settings.Playing.Value = true |
138 | timer.Value = selected:FindFirstChild(chosenmap.Value).Timer.Value |
139 | while timer.Value ~ = 0 and getaliveplayers() ~ = 0 do |
141 | message.Value = 'Time left: ' .. timer.Value |
142 | timer.Value = timer.Value - 1 |
145 | message.Value = 'Times up!' |
147 | for i = 1 ,#players do |
148 | if players [ i ] .Settings.Winner.Value = = true then |
149 | table.insert(winners,players [ i ] ) |
150 | if #winners = = 1 then |
151 | players [ i ] .leaderstats.Wins.Value = players [ i ] .leaderstats.Wins.Value + 1 |
152 | message.Value = players [ i ] .Name .. ' won the game!' |
154 | message.Value = 'Good job! You will be rewared some cash!' |
155 | players [ i ] .leaderstats.Cash.Value = players [ i ] .leaderstats.Cash.Value + 40 |
164 | if checkplayers() then |
172 | if checkplayers() then |
176 | message.Value = 'Waiting for players..' |
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