Greetings, everyone.
In one of my games, I have noticed a big lag coming from our systems and I have no idea why, but I most likely think it is related to the lag the game is handing (65+ players & big detailed map)
But either way, it should not take too long to load players. The video of it loading: https://youtu.be/ZkNP9pP7XJ4
Details:
When you press the refresh icon, it runs the ReloadList()
function that loads the code.
The function is the following: (assuming Reloading variable is a boolean)
function ReloadList(studentCallback)
if Reloading then return end
print('[C][SBLS] Reloading..')
Reloading = true
local StudentListFrame = QueryTab:WaitForChild('PlayerList')
local List = StudentListFrame:WaitForChild('List')
ClearSL()
QueryTab:WaitForChild("PlayerList"):WaitForChild("Reload").Visible = false
QueryTab:WaitForChild("PlayerList"):WaitForChild("SearchUser").Visible = false
QueryTab:WaitForChild("PlayerList"):WaitForChild("TextLabel").Visible = true
for _, Player in ipairs(PlayerList) do
if Player:GetRankInGroup(GroupID) <= StudentRankId then
local template = List:WaitForChild("TEMPLATE_USER")
local UserBlock = template:Clone();
UserBlock.Name = Player.Name:lower()
UserBlock.CanDelete.Value = true;
UserBlock.UserImage.Image = Players:GetUserThumbnailAsync(Player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size60x60);
UserBlock.Username.Text = Player.Name;
UserBlock.Year.Text = Player:GetRoleInGroup(GroupID);
UserBlock.Visible = true;
UserBlock.Parent = List;
UserBlock.LoadData.LoadDataButton.MouseButton1Click:Connect(function()
if not Players:FindFirstChild(Player.Name) then return end;
PlayerListprogress = false;
StudentListFrame.Visible = false;
--StudentListFrame:Destroy()
LoadStudentBehaviourLogs(Player, function()
studentCallback()
end)
end)
UserBlock.Oncall.Button.MouseButton1Click:Connect(function()
if not Players:FindFirstChild(Player.Name) then return end;
PlayerListprogress = false;
StudentListFrame.Visible = false;
--StudentListFrame:Destroy()
CreateOncallSession(Player, function()
studentCallback()
end)
end)
UserBlock.Profile.Button.MouseButton1Click:Connect(function()
if not Players:FindFirstChild(Player.Name) then return end;
PlayerListprogress = false;
StudentListFrame.Visible = false;
--StudentListFrame:Destroy()
LoadStudentProfile(Player, function()
studentCallback()
end)
end)
end
end
QueryTab:WaitForChild("PlayerList"):WaitForChild("Reload").Visible = true
QueryTab:WaitForChild("PlayerList"):WaitForChild("SearchUser").Visible = true
QueryTab:WaitForChild("PlayerList"):WaitForChild("TextLabel").Visible = false
print("[C][SBLS] Finished reloading")
Reloading = false
end
And the PlayerList
variable is a table consisting of every player in the server, broadcasted by the server every 1 second on a different thread using task.spawn
.
Any help is much appreciated, thank you