Im trying to update leader stats every second and change a percentage based on there Y value.
I cant really provide videos, but basically when the server is full with 20 people it freezes and causes other server timers to freeze.
The only solution I have done is disable it LOL. I cant think of anything else, I did change it from a string value to Int.
local Players = game:GetService("Players") local Index = 0 local SpawnY = 4 local LastStageY = 2468 while(wait(1)) do local allPlayers = Players:GetPlayers() for k, player in ipairs(allPlayers) do if not(player:FindFirstChild("leaderstats")) then continue end local leaderstats = player.leaderstats local progressStat = leaderstats and leaderstats:FindFirstChild("Progress") if progressStat then progressStat.Value = ((player.Character:WaitForChild("HumanoidRootPart").Position.Y - SpawnY) * 100) / (LastStageY - SpawnY) end end end
The leaderstats instance is created on a ServerScriptService file. Tied to a player added event.
local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local percentThrewRun = Instance.new("IntValue") percentThrewRun.Name = "% Done" percentThrewRun.Value = 0 percentThrewRun.Parent = leaderstats
Any help and advice is appreciated. My guess is maybe to many operations are happening for it to handle in one second on one thread. Or maybe waiting for HumanoidRootPart is freezing up the server.