So, this typically occurs when youâre creating multiple loops through an event.
For example, letâs say you placed a while
loop inside of the PlayerAdded
event.
local calls = 0
game.Players.PlayerAdded:Connect(function(plr)
while true do
calls += 1
print("Calls:",calls)
wait(1)
end
end)
⌠when one player joins the game, this loop will start adding 1 to calls
every second
⌠when a second player joins, another loop will be created - so another 1 is added to calls
every second
eventually this spirals the more players join the game.
That is the concept.
For you now, you need to two 3 things.
- Create meaningful
print
code
â In a few cases, you simply print out the value without including an identifier - this makes it extremely difficult to keep track of which values contribute to which variables.
For example
print(NATime)
print(NName)
print(NIntro)
print(NRank)
would be much better as
print("NATime:", NATime, "NNName:", NName, "NIntro:", NIntro, "NRank:", NRank) -- reduces lines written to console and suggests which each value means.
-
Track down which loops are multiplying
â By using prints correctly, you should find it much easier to identify which of your loops are spiralling and to correct them.
-
Format your code correctly
â a lot of your code has odd formatting, making it difficult to read, for example;
script.AData.Event:Connect(function(NName,NIntro,NATime,NRank,NPic)
print(NATime)
print(NName)
print(NIntro)
print(NRank)
game.ReplicatedStorage["RFs&REs"].MD:FireAllClients(NName,NIntro,NRank,NPic, GM)
repeat
wait(1)
NATime = NATime - 1
print(NATime)
game.ReplicatedStorage["RFs&REs"].Timer:FireAllClients(NATime)
until NATime == 0
Abnorm.Parent = game.ReplicatedStorage.Abnormalities
game.ServerScriptService.GameSorting.GameEnd:Fire()
workspace.BGS:Destroy()
end)
end)
this would look much better like thisâŚ
script.AData.Event:Connect(function(NName,NIntro,NATime,NRank,NPic)
print(NATime)
print(NName)
print(NIntro)
print(NRank)
game.ReplicatedStorage["RFs&REs"].MD:FireAllClients(NName,NIntro,NRank,NPic, GM)
repeat -- Correct and easily read indentation
wait(1)
NATime = NATime - 1
print(NATime)
game.ReplicatedStorage["RFs&REs"].Timer:FireAllClients(NATime)
until NATime == 0
Abnorm.Parent = game.ReplicatedStorage.Abnormalities
game.ServerScriptService.GameSorting.GameEnd:Fire()
workspace.BGS:Destroy()
end)
Doing these 3 things will help you to debug your code more effectively now and in the future.