I already use that, it’s just not shown. Here is the entire code:
Long 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
print(index, object)
table.insert(Players,object.Player.Value)
end
return Players
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 = {}
}
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)
print(ServerFolder)
print(#ServerFolder:GetAttributes())
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(ServerFolder:GetAttribute("Owner").."Server")]
local PlayersInServer = MainModule:GetPlayersFromMultiplayerServer(ServersSetting[tostring(Player).. "Server"].ServerNum)
for index, player in ipairs (MainModule:GetPlayersFromMultiplayerServer(ServersSetting[tostring(Player).."Server"].ServerNum)) do
for index, object in ipairs(player.PlayerGui.MainUI.ServerPlayer.PlayersFrame:GetChildren()) do
if object:IsA("TextButton") then
object:Destroy()
end
end
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
if ServerTable.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
if ServerTable.GameMode == 1 then
Player.PlayerGui.MainUI.ServerPlayer.OptionsFrame.GameMode.Text = "Game Mode: Story"
Player.PlayerGui.MainUI.ServerOwner.OptionsFrame.GameMode.Text = "Game Mode: Story"
elseif ServerTable.GameMode == 2 then
Player.PlayerGui.MainUI.ServerPlayer.OptionsFrame.GameMode.Text = "Game Mode: Non-NPC Escape (For First-Time Tries)"
Player.PlayerGui.MainUI.ServerOwner.OptionsFrame.GameMode.Text = "Game Mode: Non-NPC Escape (For First-Time Tries)"
else
Player.PlayerGui.MainUI.ServerPlayer.OptionsFrame.GameMode.Text = "Game Mode: NPC-Player Escape (For Experienced Tries)"
Player.PlayerGui.MainUI.ServerOwner.OptionsFrame.GameMode.Text = "Game Mode: NPC-Player Escape (For Experienced Tries)"
end
if ServerTable.GameDiff == 1 then
Player.PlayerGui.MainUI.ServerPlayer.OptionsFrame.GameDiff.Text = "Game Difficulty: Safe (Respawn with the leader, Unlimited Lives)"
Player.PlayerGui.MainUI.ServerOwner.OptionsFrame.GameDiff.Text = "Game Difficulty: Safe (Respawn with the leader, Unlimited Lives)"
elseif ServerTable.GameDiff == 2 then
Player.PlayerGui.MainUI.ServerPlayer.OptionsFrame.GameDiff.Text = "Game Difficulty: Euclid (Respawn with the leader, Limit of 5 Lives, More active threats)"
Player.PlayerGui.MainUI.ServerOwner.OptionsFrame.GameDiff.Text = "Game Difficulty: Euclid (Respawn with the leader, Limit of 5 Lives, More active threats)"
elseif ServerTable.GameDiff == 3 then
Player.PlayerGui.MainUI.ServerPlayer.OptionsFrame.GameDiff.Text = "Game Difficulty: Keter (Respawn near the leader, Limit of 3 Lives, Even More active threats)"
Player.PlayerGui.MainUI.ServerOwner.OptionsFrame.GameDiff.Text = "Game Difficulty: Keter (Respawn near the leader, Limit of 3 Lives, Even More active threats)"
elseif ServerTable.GameDiff == 4 then
Player.PlayerGui.MainUI.ServerPlayer.OptionsFrame.GameDiff.Text = "Game Difficulty: Thaumiel (Respawn near at random spots, Limit of 2 Lives, Even More active threats)"
Player.PlayerGui.MainUI.ServerOwner.OptionsFrame.GameDiff.Text = "Game Difficulty: Thaumiel (Respawn near at random spots, Limit of 2 Lives, Even More active threats)"
else
Player.PlayerGui.MainUI.ServerPlayer.OptionsFrame.GameDiff.Text = "Game Difficulty: Apollyon (No Respawning, Threats Everywhere, Limited Inventory)"
Player.PlayerGui.MainUI.ServerOwner.OptionsFrame.GameDiff.Text = "Game Difficulty: Apollyon (No Respawning, Threats Everywhere, Limited Inventory)"
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)
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