THIS IS ONLY THE PIECE OF THE SCRIPT, THE ENTIRE SCRIPT HAS 150 LINES!!!!!
spawnAnotherAt=50
nextSpawn=0
if nextSpawn<=0 then
newai=game.Lighting.Enemy:clone()
spot=math.random(1,2)
if spot==1 then
newai.Position=UDim2.new(0,0,0.65,0)
else
newai.Position=UDim2.new(0.96,0,0.65,0)
end
newai.Parent=script.Parent
if spawnAnotherAt >= 2 then
spawnAnotherAt = spawnAnotherAt -0.9
elseif spawnAnotherAt <= 2 or spawnAnotherAt == 2 then
spawnAnotherAt = 2
end
nextSpawn=spawnAnotherAt
print(spawnAnotherAt)
end
So what this piece of script does is to set the enemies spawning of a gui minigame. Between lines 13-17 is to set that spawn another at minimal number gets to two, witch means the it will spawn a the next enemy in 2 frames. But theres a problem, the spawnanotherat doesnt stop in 2, it just keeps going, making the game lag and create a lot of enemys of a time.

1 comment
If the script is copying itself then each copy is going to run and it's going to replicate forever and crash.