Line 65 saying attempt to index field (a nil value)?
local players = nil
local number = 1
local maxnumber = 0
local player = game.Players.LocalPlayer
script.Parent.Parent:WaitForChild("PlayerInfo"):WaitForChild("pName")
script.Parent.Next.MouseButton1Click:connect(function(right)
players = game.Players:GetChildren()
number = number + 1
if players[number] ~= nil then
script.Parent.Parent.PlayerInfo.Visible = true
game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
script.Parent.Parent.PlayerInfo:WaitForChild('pName').Text = players[number].Name
coroutine.resume(coroutine.create(function()
players[number].Character.Humanoid.Changed:connect(function()
if script.Parent.PlayerName.Text == players[number].Name then
script.Parent.Parent.PlayerInfo.Health.Text = math.floor(players[number].Character.Humanoid.Health)
script.Parent.Parent.PlayerInfo.Bar.Size = UDim2.new(players[number].Character.Humanoid.Health/players[number].Character.Humanoid.MaxHealth,0,.99,0)
end
end)
end))
if players[number].Name ~= player.Name then
script.Parent.PlayerName.Text = players[number].Name
else
script.Parent.Parent.PlayerInfo.Visible = false
script.Parent.PlayerName.Text = "Nobody"
end
elseif players[number] == nil then
number = 1
game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
if players[number].Name ~= player.Name then
script.Parent.PlayerName.Text = players[number].Name
else
script.Parent.Parent.PlayerInfo.Visible = false
script.Parent.PlayerName.Text = "Nobody"
end
end
end)
script.Parent.Previous.MouseButton1Click:connect(function(left)
players = game.Players:GetChildren()
maxnumber = #players+1
number = number - 1
if players[number] ~= nil then
script.Parent.Parent.PlayerInfo.Visible = true
game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
script.Parent.Parent.PlayerInfo:WaitForChild('pName').Text = players[number].Name
coroutine.resume(coroutine.create(function()
players[number].Character.Humanoid.Changed:connect(function()
if script.Parent.PlayerName.Text == players[number].Name then
script.Parent.Parent.PlayerInfo.Health.Text = math.floor(players[number].Character.Humanoid.Health)
script.Parent.Parent.PlayerInfo.Bar.Size = UDim2.new(players[number].Character.Humanoid.Health/players[number].Character.Humanoid.MaxHealth,0,.99,0)
end
end)
end))
if players[number].Name ~= player.Name then
script.Parent.Parent.PlayerInfo.Visible = true
script.Parent.PlayerName.Text = players[number].Name
else
script.Parent.Parent.PlayerInfo.Visible = false
script.Parent.PlayerName.Text = "Nobody"
end
elseif players[number] == nil then
number = maxnumber
game.Workspace.CurrentCamera.CameraSubject = players[number].Character.Humanoid
if players[number].Name ~= player.Name then
script.Parent.PlayerName.Text = players[number].Name
else
script.Parent.Parent.PlayerInfo.Visible = false
script.Parent.PlayerName.Text = "Nobody"
end
end
end)

2 comments
A little more context would be nice. What is this script supposed to be doing?
I'm just here learning from people's issues since I'm fairly inexperienced. Could the issue be that on line 64 the number gets set to 0 and messing things up on line 65 since Lua tables start at 1 instead of the typical 0? Now I'll be off looking up how coroutines work :D