Script timeout when two players joins the game

Hi, so I have an issue when two players joins my game with a script which manage players.
This script has to manage thier data and then launch external scripts to make thier game works,
but if it doesn’t, they cannot play the game.

So the issue is this one, every time a second player join the game it make two error message

1st:

Script timeout: exhausted allowed execution time
       Stack Begin
       Script 'ServerScriptService.Scripts.Modules.Management', Line 300
       Stack End

2nd:

ServerScriptService.Scripts.Automatic.PlayerManagement:11: Script timeout: exhausted allowed execution time
       Stack Begin
       Script 'ServerScriptService.Scripts.Modules.Manangement', Line 316 - function PlayerAdd
       Script 'ServerScriptService.Scripts.Automatic.PlayerManagement', Line 11
       Stack End

I haven’t tried a solution, I have took a look to some forums post with the same error message but nothing correspond to my case, it’s was working correctly at the first time. Something happened, I don’t know what.

Here’s the code :

Management (Module script)
--[[
Game manager for Neighblox.

In frist, the manager will prepare tables and requirements
in second, it's will load needed data.
in third, it's get ready to be used to edit or add user's data such as money, playtime, job and etc.
in last, it's launch automatics data editor and register everything into a SQL database to show it on neighblox.mceteams.com.

]]--

--[[
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘β–„β–„ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β•šβ•β•β•β•β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•β• β•šβ•β•β–€β–€β•β•  β•šβ•β•β•β•β•β• β•šβ•β•β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•     β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•β•β•   β•šβ•β•   β•šβ•β•β•β•β•β•β•
]]--

-- Services
local LocalizationService = game:GetService("LocalizationService")
local ServerScriptService = game:GetService("ServerScriptService")
local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local GamePasseService = game:GetService("GamePassService")
local TextService = game:GetService("TextService")
local RunService = game:GetService("RunService")
local StarterGui = game:GetService("StarterGui")
local GuiService = game:GetService("GuiService")
local Players = game:GetService("Players")

--[[
β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—    β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•    β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•
β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—    β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β•  β•šβ•β•β•β•β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘   β•šβ•β•β•β•β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
β•šβ•β•     β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•  β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•    β•šβ•β•β•šβ•β•     β•šβ•β•β•šβ•β•      β•šβ•β•β•β•β•β• β•šβ•β•  β•šβ•β•   β•šβ•β•   β•šβ•β•β•β•β•β•β•
]]--

-- Local
local MainModule = script -- Main module script.

-- Elements
local AdministrationManager = require(MainModule.Elements.Administration) -- Administration manager.
local CurrentDataManager = require(MainModule.Elements.CurrentData) -- CurrentData manager.
local MultiplerManager = require(MainModule.Elements.Multiplier) -- Multipliers manager.
local BuildingManager = require(MainModule.Elements.Building) -- Building Mode manager.
local EmotionsManager = require(MainModule.Elements.Emotions) -- Emotions mananger.
local ActionsManager = require(MainModule.Elements.Actions) -- Actions mananger.
local PlotsManager = require(MainModule.Elements.Plots) -- Plots mananger.
local JobsManager = require(MainModule.Elements.Jobs) -- Jobs mananger.
local DataManager = require(MainModule.Elements.Data) -- Data mananger.

-- Packages & External modules
local BannerNotification = require(ReplicatedStorage.BannerNotification_Storage.BannerNotificationModule)
local Signal = require(MainModule.Packages.GoodSignal) -- Events manager in scripts.
local Utility = require(MainModule.Packages.Utility) -- Utility module.

--[[
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—  β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—     β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—    β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•
β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•    β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—    β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘   β•šβ•β•β•β•β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
 β•šβ•β•β•β•β•β•    β•šβ•β•   β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•    β•šβ•β•β•šβ•β•     β•šβ•β•β•šβ•β•      β•šβ•β•β•β•β•β• β•šβ•β•  β•šβ•β•   β•šβ•β•   β•šβ•β•β•β•β•β•β•
]]--

-- Types


-- Instances
local Plots = game.Workspace:WaitForChild("Plots", 3000) -- Plots folder in Workspace.
local UIRemotes = ReplicatedStorage.Remotes.Ui
local GameRemotes = ReplicatedStorage.Remotes.Game

-- Banner Notifications Configs
local ErrorCFG = {
	.3, Color3.fromRGB(170, 0, 0),
	0, Color3.fromRGB(255, 255, 255),
}

local SuccessCFG = {
	.3,	Color3.fromRGB(0, 170, 0),
	0, Color3.fromRGB(255, 255, 255),
}

local BlueDefaultCFG = {
	0, Color3.fromRGB(0, 170, 255),
	0, Color3.fromRGB(255, 255, 255),
}

local WhiteDefaultCFG = {
	0, Color3.fromRGB(255, 255, 255),
	0, Color3.fromRGB(0, 170, 255),
}

local DefaultCFG = {
	.3, Color3.fromRGB(0, 0, 0),
	0, Color3.fromRGB(255, 255, 255),
}

--[[
β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•    β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•
β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•   β–ˆβ–ˆβ•‘   
β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β•  β•šβ•β•β•β•β–ˆβ–ˆβ•‘    β•šβ•β•β•β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘   
β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   
β•šβ•β•     β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•  β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•    β•šβ•β•β•β•β•β•β•   β•šβ•β•   β•šβ•β•  β•šβ•β•β•šβ•β•  β•šβ•β•   β•šβ•β•   
]]--

local Management = {}
Management.__index = Management

--[[
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘        β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘        β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β•šβ•β•β•β•β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘     β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
β•šβ•β•      β•šβ•β•β•β•β•β• β•šβ•β•  β•šβ•β•β•β• β•šβ•β•β•β•β•β•   β•šβ•β•   β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β•  β•šβ•β•β•β•β•šβ•β•β•β•β•β•β•
]]--

-- Table (Data)
local PlayersDict = {}
Management.PlayersDictionary = PlayersDict

-- Get functions

function Management.getPlayer(UID) -- get a player by his UID.
	local match = Management.PlayersDictionary[UID]
	if match then
		return match
	else
		error('Player ( '.. UID ..' ) has not been founded.')
	end
end

-- ###############################################################################################################################

function Management.PlayerAdd(Player: Player) -- Add the player, his data and prepare the player.
	local PlayerUI = Player.PlayerGui

	-- GET READY TABLES --
	if Player:GetRankInGroup(8804274) < 246 then -- Developement safety protection.
		if not (Player.UserId == 338411546 or Player.UserId == 59654145 or Player.UserId == 3539718031 or Player.UserId == 1267348904) then
			Player:Kick("Not allowed to join at the moment.")
		end
	end

	local self = {}
	setmetatable(self, Management)
	PlayersDict[Player.UserId] = self -- Attach the table to player's UID.

	-- Permanent data ( saved )
	self.Player = Player 
	self.UID = Player.UserId -- Set the UID to the table.
	self.Demands = { -- Prepare the table of demands.
		Hygiene = 100, 
		Hunger = 100,
		Energy = 100,
		Health = 100,
		Social = 100,
		Fun = 100
	}

	self.Money = 2500 -- Prepare Money.
	self.Playtime = 0 -- Prepare Playtime'Co.
	
	-- Settings ( saved )
	self.UITheme = "Light" -- Prepare the Theme.
	self.UIAnimations = true
	self.Lightning = "normal"
	self.PrimaryColor = Color3.fromRGB(0, 170, 255)

	-- Temporary data ( not saved ).
	self.Job = "Manager" -- Event of job.
	self.Plot = 0 -- Event of plot.
	self.Actions = {}  -- Event of actions.
	self.Effects = {}  -- Event of effects.
	self.Emotion = "Default" -- Event of emotions.
	self.TempID = self.UID.. "_" ..Utility.generateUID(11).. "_T"
	self.CustomPlot = false
	--MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, 784646874) -- Prepare gamepass value to share.
	self.Configs = {
		Error = ErrorCFG,
		Default = DefaultCFG,
		Success = SuccessCFG,
		BlueDefault = BlueDefaultCFG,
		WhiteDefault = WhiteDefaultCFG
	}
	
	self.Managers = {
		AdministrationManager = AdministrationManager,
		CurrentDataManager = CurrentDataManager,
		MultiplerManager = MultiplerManager,
		BuildingManager = BuildingManager,
		EmotionsManager = EmotionsManager,
		ActionsManager = ActionsManager,
		PlotsManager = PlotsManager,
		JobsManager = JobsManager,
		DataManager = DataManager
	}

	-- Safety data ( not saved ).
	self.Teleporting = false -- Prepare safety anti spam protection 1.
	self.Purchasing = false -- Prepare safety anti spam protection 2.
	self.InBuildingMode = false

	-- Events --
	self.MessagePromter = Signal.new()

	self.DemandsChanged = Signal.new()
	self.ActionsChanged = Signal.new()
	self.EffectsChanged = Signal.new()
	self.EmotionChanged = Signal.new() 
	self.MoneyChanged = Signal.new()
	self.PlotChanged = Signal.new()
	self.JobChanged = Signal.new()

	local success, message = pcall(function() -- Protection to prevent data loss.

		task.spawn(function() -- Load the player's money/currency.
			if not (DataManager.Load(Player, "playtime") == 0 or DataManager.Load(Player, "playtime") == nil) then
				self.Money = DataManager.Load(Player, "money")
			end
		end)

		task.spawn(function() -- Load the player's playtime.
			if not (DataManager.Load(Player, "playtime") == nil) then
				self.Playtime = DataManager.Load(Player, "playtime")
			end
		end)

		task.spawn(function() -- Load the player's demands.
			if not (DataManager.Load(Player, "demands") == nil) then
				self.Demands = DataManager.Load(Player, "demands")
			end
		end)
		
		task.spawn(function() -- Load the player's UI Theme.
			if not (DataManager.Load(Player, "UITheme") == nil) then
				self.UITheme = DataManager.Load(Player, "UITheme")
			end
		end)
		
		task.spawn(function() -- Load the player's UI Animations setting.
			if not (DataManager.Load(Player, "UIAnimations") == nil) then
				self.UIAnimations = DataManager.Load(Player, "UIAnimations")
			end
		end)

		task.spawn(function() -- Load data ID
			if not (DataManager.Load(Player, "dataID") == nil ) then
				self.DataID = DataManager.Load(Player, "dataID")
			else
				self.DataID = self.UID.. "_" ..Utility.generateUID(64).. "_D"
			end
		end)

		task.spawn(function() -- Load data ID
			if not ( DataManager.Load(Player, "Joindate") == nil ) then
				self.Joindate = DataManager.Load(Player, "Joindate")
			else
				self.Joindate = os.date()
			end
		end)
		
		task.spawn(function() -- Load Theme
			if not ( DataManager.Load(Player, "Theme") == nil ) then
				self.Theme = DataManager.Load(Player, "Theme")
			else
				self.Theme = "Light"
			end
		end)

		task.defer(function() -- Check if the player has joined for the first time.
			if self.Playtime == 0 then 
				--Prompter.Prompt("Ok", "Message", "\nWelcome to Neighblox.\nto understand how this game work, please follow the first steps.", "tuto")
			end
		end)
	end)

	if not success then -- Verify if the player's data has loaded.
		game.ReplicatedStorage.Remotes.Game.Data.Ended:FireClient(self.Player, "DataFailed")
		wait(3)
		Player:Kick("Your data has failed to load.")
	end

	-- Add functions to execute automatically.

	task.spawn(function() -- Set the player's plot.
		local Occupied = true
		if not (self.CustomPlot == true) then
			local PlotNumber = 0

			repeat
				PlotNumber = math.random(1, 16)
				if Plots:FindFirstChild("Plot_".. PlotNumber).Occupied.Value == true then
					Occupied = true
				else
					Occupied = false
					Plots:FindFirstChild("Plot_".. PlotNumber).Occupied.Value = true
					self.Plot = tonumber(PlotNumber)
				end

			until Occupied == false
		end
	end)




	-- Launch automatic things
	task.defer(function() -- Wait everything is ready.
		--game.ReplicatedStorage.:FireClient(self.Player, "Open", "Menu")

		--task.spawn(function() -- Automatic playtime.
		--	RunService.Heartbeat:Connect(function() -- Run service heartbeat.
		--		self.Playtime += 1 -- Add a second every second.
		--		wait(1)
		--	end)
		--end)

		task.spawn(function() -- Enable some server scripts into player's files.
			PlayerUI.Interface.CornerRight.Main.Container.Money.CurrentMoney.AutomaticUpdate.Enabled = true
			PlayerUI.Interface.CornerRight.Main.Container.Emotions.Title.AutomaticSet.Enabled = true
			PlayerUI.Interface.Demands.AutomaticValue.Enabled = true
		end)

		--task.spawn(function()
		--	EmotionsManager:DemandsLaunch(self)
		--end)

		--task.spawn(function()
		--	self.DemandsChanged:Connect(function()
		--		EmotionsManager:EmotionsUpdate(self)
		--	end)
		--end)
	end)

	PlayerUI.properties.UISettings:SetAttribute("Theme", self.UITheme)
	PlayerUI.properties.UISettings:SetAttribute("Animations", self.UIAnimations)
	
	--AdministrationManager:RegisterData(self, true)
	return self
end

-- SET --

-- ###############################################################################################################################

function Management:setJob(leave: boolean, Forced: boolean, text: nil) -- Reset and set the player's job.
	if leave == true or text== nil then
		JobsManager.Leave(nil, self, Forced)
	elseif not (text == nil and leave == true) then
		JobsManager.Change(nil, self, text, Forced)
	end

	return self
end

-- ###############################################################################################################################

function Management:setCurrentAction(text: string, Multiplier: number) -- Reset and set the player's current action.
	return self
end

-- ###############################################################################################################################

function Management:setMoney(int: number) -- Reset and set the player's money.
	return self
end

-- ###############################################################################################################################

function Management:setPlot(int: number) -- Set the player's plot.
	return self
end

-- ###############################################################################################################################

function Management:setEmotions(text: string) -- Set the player emotion.	
	return self
end

-- ###############################################################################################################################

function Management:setEffect(text) -- Reset and set a new effect.
	return self
end

-- ADD --

-- ###############################################################################################################################

function Management:addMoney(int: number) -- Add money to the player.
	return self
end

-- ###############################################################################################################################

function Management:addEffect(text) -- Add an effect to the player.
	return self
end

-- ###############################################################################################################################

function Management:addAction(text, Multiplier)
	return self
end

-- ###############################################################################################################################

function Management:ToPlot(from)
	local Player:Player = self.Player
	local Character = Player.Character
	local PlayersPlot = game.Workspace.Plots:FindFirstChild("Plot_".. self.Plot)
	local PlotTeleportPart = PlayersPlot.Teleport
	local PlayerGui = Player.PlayerGui

	self.Teleporting = true
	PlayerGui.Interface.Loading.LoadingFrame.Title.Text = "Teleporting"
	PlayerGui.Interface.Loading.LoadingFrame.Container.Progress.Value = 10
	UIRemotes.BigLoadingRemote:FireClient(Player, "Open")
	wait(2)
	if from == "Start" then
		GameRemotes.Menu.rCameraAnimation:FireClient(Player, "Stop")
	end
	Character:WaitForChild("HumanoidRootPart").CFrame = PlotTeleportPart.CFrame + Vector3.new(0, 5, 0)
	PlayerGui.Interface.Loading.LoadingFrame.Container.Progress.Value = 100
	wait(2)
	UIRemotes.BigLoadingRemote:FireClient(Player, "Close")
	wait(2)
	PlayerGui.Interface.Loading.LoadingFrame.Title.Text = "Loading"
	PlayerGui.Interface.Loading.LoadingFrame.Container.Progress.Value = 0
	self.Teleporting = false
end

-- ###############################################################################################################################

function Management:BuildingMode(action, target) -- not working I broke it...
	--if action == "Leave" and self.InBuildingMode == true then
	--	self.InBuildingMode = false
	--	print("Closing building manager")
	--	BuildingManager:End(self)
	--elseif action == "Begin" and self.InBuildingMode == false then
	--	self.InBuildingMode = true
	--	print("Starting building manager")
	--	BuildingManager:Start(self, target)
	--end
end

return Management
PlayerManagement ( Script )
game.Players.PlayerAdded:Connect(function(Plr)
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local GameRemotes = ReplicatedStorage.Remotes.Game
	local UIRemotes = ReplicatedStorage.Remotes.Ui
	
	GameRemotes.Data.Load.OnServerEvent:Connect(function(Player)
		
		local Manager = require(game:GetService("ServerScriptService").Scripts.Modules.Manangement)
		local PhysicsService = game:GetService("PhysicsService")
				
		Manager.PlayerAdd(Player)
		GameRemotes.Data.Ended:FireClient(Player, "DataEnd")
			
		local character = Player.Character
			
		PhysicsService:RegisterCollisionGroup("Characters")
		PhysicsService:CollisionGroupSetCollidable("Characters", "Characters", false)

		local function onDescendantAdded(descendant)
			if descendant:IsA("BasePart") then
				descendant.CollisionGroup = "Characters"
			end
		end

		task.defer(function()
			for _, descendant in character:GetDescendants() do
				onDescendantAdded(descendant)
			end
			character.DescendantAdded:Connect(onDescendantAdded)
		end)
	end)
	
	GameRemotes.Moving.Teleportation.OnServerEvent:Connect(function(Player, value)
		if value == "TeleportStarting" then
			local Manager = require(game:GetService("ServerScriptService").Scripts.Modules.Manangement)
			local PManage = Manager.getPlayer(Player.UserId)
			if not (PManage.CustomPlot == true) then
				--if PManage.plot == 0 or PManage.plot == nil then
				--	Player.PlayerGui.Interface.Loading.LoadingFrame.Title.Text = "Error"
				--	Player.PlayerGui.Interface.Loading.LoadingFrame.Container.Progress.Value = -100
				--	Player:Kick("An error occured while loading your data.")
				--elseif PManage.CustomPlot == false and not (PManage.plot == 0) and not (PManage.plot == nil) then
					local PlayersPlot = game.Workspace.Plots:FindFirstChild("Plot_".. PManage.Plot)
					local PlotTeleportPart = PlayersPlot.Teleport
					
					PManage:ToPlot("Start")
					Player.PlayerGui.Menu.StartMenu.ReadyToShow.Value = true
				--end
			else
				UIRemotes.BigLoadingRemote:FireClient(Player, "Open")
				UIRemotes.BigLoadingRemote:FireClient("Text", "Getting plots ready...")
				Player.PlayerGui.Interface.Loading.LoadingFrame.Container.Progress.Value = 50
				wait(10)
				UIRemotes.BigLoadingRemote:FireClient("Text", "Plots are not ready !")
				Player.PlayerGui.Interface.Loading.LoadingFrame.Container.Progress.Value = 100
			end
		end
	end)
	
	GameRemotes.Data.Reset.OnServerEvent:Connect(function(Player)
		local Manager = require(game:GetService("ServerScriptService").Scripts.Modules.Manangement)
		local PManage = Manager.getPlayer(Player.UserId)
		
		--PManage:DeleteData("All")
		--repeat wait() until PManage.ResetedData == true
		--PManage.ResetedData = false
		
		wait(10)
		UIRemotes.SmallLoadingRemote:FireClient(Player, "Close")
		wait(0.5)
		UIRemotes.OptionsRemote:FireClient(Player, "Open")
	end)
	wait()
end)

As you may think, everything is working for a single player (preview):

If someone could help me to solve this problem, thank you in advance…

1 Like

This post is very suspicious.

why did you place those events inside the PlayerAdded event?
why do you have server code mixed with client code in the management module?

I need you to explain yourself, sir.

Hi, so to prevent some hack or smth else, every one know using server scripts is the best way to prevent hackers from accessing our codes isn’t,

I just remarked I did a mistake on the PlayerManagement I forgot to remove PlayerAdded event.
But the problem isn’t there.

So my method is this one:

  1. A local script in ReplicatedFirst moves up a GUI and wait for the game to load.

  2. When it’s ready, it’s trigger the GameRemotes.Data.Load remote event on the ReplicatedStorage

  3. When triggered it’s will execute the ModuleScript in ServerScriptService β€œManagement” ( Manager in the case of PlayerManagement )

  4. The ModuleScript will add the Player to a table and create another table specific to the player.

But my problem is when the ModuleScript is executed with two Players, it’s used to work before, but some how it’s broke even I didn’t touched anything on the ModuleScript but it’s get Timed out with two Players…

Script timeout: exhausted allowed execution time means the script is frozen basically due to doing something like while true do end with no wait. You can try adding a wait to your repeat block on like 300 in Management:

repeat
	PlotNumber = math.random(1, 16)
	if Plots:FindFirstChild("Plot_".. PlotNumber).Occupied.Value == true then
		Occupied = true
	else
		Occupied = false
		Plots:FindFirstChild("Plot_".. PlotNumber).Occupied.Value = true
		self.Plot = tonumber(PlotNumber)
	end
	task.wait() -- wait added here to prevent script freezing
until Occupied == false
1 Like

Ok, so I added:

It’s worked correctly,
I did a mistake ( again )
but, before the error happened, I used to use the code like I sent it and this error had never appeared…

So now it’s working thank you so much again, you saved me like 1 day of searching.
And I hope to not make the same mistake later.

1 Like