GUI Server Issue

Hey!
I’m making a server system and I ran into display issue with the players.

Player
image

Server Owner
image

Code:

	local PlayersInServer = MainModule:GetPlayersFromMultiplayerServer(ServerNum)
	
	for index, value in ipairs(PlayersInServer) do
		local ServerPlayerClone = ServerStorageService.UIStuff.Junk.ServersUI.PLAYERNAME:Clone()
		ServerPlayerClone.Name = tostring(Player)
		ServerPlayerClone.Parent = value.PlayerGui.MainUI.ServerPlayer.PlayersFrame
		
		local ServerOwnerClone = ServerStorageService.UIStuff.Junk.ServersUI.PLAYERNAME:Clone()
		ServerOwnerClone.Name = tostring(Player)
		ServerOwnerClone.Parent = value.PlayerGui.MainUI.ServerOwner.PlayersFrame
	end

Sorry if there isn’t much info to this. Feel free to ask for more.

Full Code
local MainModule = {}
local ServersSetting = {}

function MainModule.EnableUI(UneededTable, player : Player, UIName)
	
	if player.ClassName ~= "Player" then warn("Not a valid player!") return end
	local FindMainUI = player.PlayerGui:FindFirstChild(tostring(UIName))
	if FindMainUI and FindMainUI:IsA("ScreenGui") then
		player.PlayerGui.MainUI.Enabled = true
		local FindMainFrame = FindMainUI:FindFirstChild("MainFrame")
		if FindMainFrame and string.find(FindMainFrame.ClassName, "Frame") then
			FindMainFrame.Visible = true
		end
	end
end

function MainModule.DisableUI(UneededTable, player : Player, UIName)
	if player.ClassName ~= "Player" then warn("Not a valid player!") return end
	
	local FindMainUI = player.PlayerGui:FindFirstChild(tostring(UIName))
	if FindMainUI and FindMainUI:IsA("ScreenGui") then
		player.PlayerGui.MainUI.Enabled = false
	end
end

function MainModule.CheckIfValueIs(UneededTable : nil, Object, CheckIfIsA)
	local IsA = false
	local Success, FailMessage = pcall(function()
		if type(Object) == tostring(CheckIfIsA) or typeof(Object) == tostring(CheckIfIsA) or Object:IsA(CheckIfIsA) then
			IsA = true
		else
			warn(type(Object), typeof(Object))
		end
	end)
	if Success and IsA then
		return true
	else
		return false
	end
end

function MainModule.RetrieveFrameUI(UneededTable : nil, Player : Player, ScreenGuiName : string, FrameName : string)
	local CheckIfPlayerIsAPlayer = MainModule:CheckIfValueIs(Player, "Player")
	if CheckIfPlayerIsAPlayer == true then
		local FindScreenUI = Player.PlayerGui:FindFirstChild(ScreenGuiName)
		if FindScreenUI then
			local FindFrameUI = FindScreenUI:FindFirstChild(FrameName)
			if FindFrameUI then
				return FindFrameUI
			end
		end
	else
		warn(tostring(Player), "Is not a valid player!")
	end
end

function MainModule.GetPlayersFromMultiplayerServer(UndeededTable : nil, ServerNum : number)
	local ReplicatedStorageService = game:GetService("ReplicatedStorage")
	local FindServer = ReplicatedStorageService.ServersInfo.Servers:FindFirstChild("Server"..ServerNum)
	local Players = {}
	
	for index, object in ipairs(FindServer.Players:GetChildren()) do
		table.insert(Players,object.Player.Value)
	end
	return Players
end

function MainModule.GetOwnerFromMultiplayerServer(UneededTable: nil, ServerNum: number)
	local ReplicatedStorageService = game:GetService("ReplicatedStorage")
	local FindServer = ReplicatedStorageService.ServersInfo.Servers:FindFirstChild("Server"..ServerNum)

	for index, object in ipairs(FindServer.Players:GetChildren()) do
		if object:GetAttribute("IsOwner") == true then
			return object
		end
	end
end

function MainModule.CreateMultiplayerServer(UneededTable : nil, Player : Player)
	print(Player)
	local PlayersService = game:GetService("Players")
	local ServerStorageService = game:GetService("ServerStorage")
	local ReplicatedStorageService = game:GetService("ReplicatedStorage")
	
	local GetPlayers = PlayersService:GetPlayers()
	
	ServersSetting[tostring(Player).. "Server"] = {
		ServerNum = 0,
		BanPlayers = false,
		GameDiff = 1,
		MaxPlayers = 4,
		GameMode = 1,
		AmountOfPlayersInServer = 1,
		BannedPlayers = {}
	}
	ServersSetting[tostring(Player).."ServerInfo"] = {
		BanPlayers_true = "Ban Players from Sever (Instead of kicking) Status: Enabled",
		BanPlayers_false = "Ban Players from Sever (Instead of kicking) Status: Disabled"
		
	}
	for index, UI in ipairs(Player.PlayerGui.MainUI:GetChildren()) do
		UI.Visible = false
	end
	
	Player.PlayerGui.MainUI.ServerOwner.Visible = true
	local ServerFolder = ReplicatedStorageService.ServersInfo.Templates.ServerNUMBER:Clone()
	
	ServerFolder.Parent = ReplicatedStorageService.ServersInfo.Servers
	
	local AmountOfSevers = #ReplicatedStorageService.ServersInfo.Servers:GetChildren()
	
	ServerFolder.Name = "Server"..AmountOfSevers
	
	ServersSetting[tostring(Player).."Server"].ServerNum = AmountOfSevers
	
	local OwnerFolder = Instance.new("Folder", ServerFolder.Players)
	OwnerFolder.Name = tostring(Player)
	OwnerFolder:SetAttribute("IsOwner", true)
	local OwnerPlayer = Instance.new("ObjectValue", OwnerFolder)
	OwnerPlayer.Name = "Player"
	OwnerPlayer.Value = Player
	
	ServerFolder:SetAttribute("Owner", tostring(Player))
	warn(ServerFolder.Parent)
	
	for index, PlayerObject in ipairs(GetPlayers) do
		local ServersUI = PlayerObject.PlayerGui.MainUI.Servers
		local CreateServerJoinUI = ServerStorageService.UIStuff.Junk.ServersUI.Server:Clone()
		CreateServerJoinUI.Parent = PlayerObject.PlayerGui.MainUI.Servers.ServersFrame
		CreateServerJoinUI.Name = "Server"..ServersSetting[tostring(Player).."Server"].ServerNum	
		CreateServerJoinUI:SetAttribute("ServerNum", ServersSetting[tostring(Player).."Server"].ServerNum)
		CreateServerJoinUI.Text = "Sever "..ServersSetting[tostring(Player).. "Server"].ServerNum.." - Players "..ServersSetting[tostring(Player).. "Server"].AmountOfPlayersInServer.. " / " ..ServersSetting[tostring(Player).. "Server"].MaxPlayers
	end
	for index, player in ipairs (MainModule:GetPlayersFromMultiplayerServer(ServersSetting[tostring(Player).."Server"].ServerNum)) do
		local PlayersFrameClone = ServerStorageService.UIStuff.Junk.ServersUI.PLAYERNAME:Clone()
		PlayersFrameClone.Name = tostring(Player)
		PlayersFrameClone.Text = tostring(Player)
		PlayersFrameClone.Parent = player.PlayerGui.MainUI.ServerPlayer.PlayersFrame

		local OwnersFrameClone = ServerStorageService.UIStuff.Junk.ServersUI.PLAYERNAME:Clone()
		OwnersFrameClone.Name = tostring(Player)
		OwnersFrameClone.Text = tostring(Player)
		OwnersFrameClone.Parent = player.PlayerGui.MainUI.ServerOwner.PlayersFrame
	end
	
end

function MainModule.JoinMultiplayerServer(UneededTable : nil, Player : Player, ServerNum : number)
	local PlayersService = game:GetService("Players")
	local ServerStorageService = game:GetService("ServerStorage")
	local ReplicatedStorageService = game:GetService("ReplicatedStorage")
	
	
	local ServerFolder = ReplicatedStorageService.ServersInfo.Servers:FindFirstChild("Server"..ServerNum)
	local PlayerFolder = Instance.new("Folder", ServerFolder.Players)
	PlayerFolder.Name = tostring(Player)
	local OwnerPlayer = Instance.new("ObjectValue", PlayerFolder)
	OwnerPlayer.Name = "Player"
	OwnerPlayer.Value = Player
	
	Player.PlayerGui.MainUI.ServerPlayer.Visible = true
	
	
	local ServerTable = ServersSetting[tostring(MainModule:GetOwnerFromMultiplayerServer(ServerNum)).."Server"]
	local ServerInfoTable = ServersSetting[tostring(MainModule:GetOwnerFromMultiplayerServer(ServerNum)).."ServerInfo"]
	
	ServerTable.AmountOfPlayersInServer += 1
	
	Player.PlayerGui.MainUI.ServerOwner.OptionsFrame.BanPlayers.Text = ServerInfoTable["BanPlayers_"..tostring(ServerTable.BanPlayers)]
	
	local PlayersInServer = MainModule:GetPlayersFromMultiplayerServer(ServerNum)
	
	for index, value in ipairs(PlayersInServer) do
		local ServerPlayerClone = ServerStorageService.UIStuff.Junk.ServersUI.PLAYERNAME:Clone()
		ServerPlayerClone.Name = tostring(Player)
		ServerPlayerClone.Parent = value.PlayerGui.MainUI.ServerPlayer.PlayersFrame
		
		local ServerOwnerClone = ServerStorageService.UIStuff.Junk.ServersUI.PLAYERNAME:Clone()
		ServerOwnerClone.Name = tostring(Player)
		ServerOwnerClone.Parent = value.PlayerGui.MainUI.ServerOwner.PlayersFrame
	end
	
	
end

function MainModule.RetrieveMultiplayerSettings(UneededTable : nil, ServerNum : number)
	local ReplicatedStorageService = game:GetService("ReplicatedStorage")
	local FindServer = ReplicatedStorageService.ServersInfo.Servers:FindFirstChild("Server"..ServerNum)
	if FindServer then
		MainModule:GetPlayersFromMultiplayerServer(ServerNum)
	end
end

function MainModule.UpdateSettings(UneededTable : nil, Owner : Player, SettingName)
	local FindSettingTable = ServersSetting[tostring(Owner).."Server"]
	if FindSettingTable then
		if SettingName == "BanPlayers" then
			FindSettingTable.BanPlayers = not FindSettingTable.BanPlayers
			local PlayersInServer = MainModule:GetPlayersFromMultiplayerServer(FindSettingTable.ServerNum)
			for index, player in ipairs(PlayersInServer) do
				if FindSettingTable.BanPlayers == true then
					player.PlayerGui.MainUI.ServerPlayer.OptionsFrame.BanPlayers.Text = "Ban Players from Sever(Instead of kicking) Status: Enabled"
					player.PlayerGui.MainUI.ServerOwner.OptionsFrame.BanPlayers.Text = "Ban Players from Sever(Instead of kicking) Status: Enabled"
				else
					player.PlayerGui.MainUI.ServerPlayer.OptionsFrame.BanPlayers.Text = "Ban Players from Sever(Instead of kicking) Status: Disabled"
					player.PlayerGui.MainUI.ServerOwner.OptionsFrame.BanPlayers.Text = "Ban Players from Sever(Instead of kicking) Status: Disabled"
				end
			end
		end
	end
end

function MainModule.KickPlayer(UneededTable : nil, ServerNum: number, PlayerToKick : Player, Kicker : Player)
	local ReplicatedStorageService = game:GetService("ReplicatedStorage")
	local PlayersService = game:GetService("Players")
	local FindServer = ReplicatedStorageService.ServersInfo.Servers:FindFirstChild("Server"..ServerNum)
	if FindServer then
		local FindPlayer = FindServer:FindFirstChild(tostring(PlayerToKick))
		if FindPlayer then
			local Owner = PlayersService:FindFirstChild(tostring(FindServer:GetAttribute("Owner"))) 
			print(Owner)	
		end
	end
end

return MainModule

Issue not solved at all. I have tried printing everything and no issues can be found. It’s something to with the for loop in the first code, because it only loops once, but there is two values (not nil) in it.

Anyone willing to help? I seriously cannot find out what is wrong.

Can you give more details about what the main issue is?

Look at the two photos I provided. The owner can see all the players (the intention) whereas the player view only shows them, not everyone else.