--// initialize functions //--


function resetGui()
	script.Parent.GuiActive.Value = false
	script.Parent.Parent.ChangePlayer.Visible = false
	script.Parent.Holder.PlayerName.Text = "NOBODY"
	viewingNumber = 1
	game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end

function moveRight()
	playerTable = game.Players:GetChildren()
	
	viewingNumber = viewingNumber + 1
	
	if playerTable[viewingNumber] == nil then
		viewingNumber = 1
	end
	
	if playerTable[viewingNumber] ~= nil then
		game.Workspace.CurrentCamera.CameraSubject = playerTable[viewingNumber].Character.Humanoid
		if playerTable[viewingNumber].Name ~= player.Name then
			script.Parent.Holder.PlayerName.Text = playerTable[viewingNumber].Name:upper()
		else 
			script.Parent.Holder.PlayerName.Text = "NOBODY"
		end
	end
end

function moveLeft()
	playerTable = game.Players:GetChildren()
	local maxNumber = #playerTable
	
	viewingNumber = viewingNumber - 1
	
	if playerTable[viewingNumber] == nil then
		viewingNumber = maxNumber
	end
	
	if playerTable[viewingNumber] ~= nil then
		game.Workspace.CurrentCamera.CameraSubject = playerTable[viewingNumber].Character.Humanoid
		if playerTable[viewingNumber].Name ~= player.Name then
			script.Parent.Holder.PlayerName.Text = playerTable[viewingNumber].Name:upper()
		else 
			script.Parent.Holder.PlayerName.Text = "NOBODY"
		end
	end
end

function checkTeam(color)
	for i,v in pairs(script.Parent.Parent.AllowedTeams:GetChildren()) do
		if v.Value == game.Players.LocalPlayer.TeamColor then
			return true
		end
	end
	return false
end
