Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

This code only runs once and never runs again even with a while wait loop?

Asked by 2 years ago

Title.

Here is my code:

01local TweenService = game:GetService("TweenService")
02local RS = game:GetService("ReplicatedStorage")
03 
04local enemiesFolder = RS.Enemies
05local enemySpawn = workspace.EnemySpawns:GetChildren()
06local moveToParts = workspace.MoveToParts:GetChildren()
07 
08local randomSpawn = enemySpawn[math.random(1, #enemySpawn)]
09local randomMoveToPart = moveToParts[math.random(1, #moveToParts)]
10 
11local function Round1()
12 
13    local Round1Enemy = enemiesFolder.Enemy1:Clone()
14    Round1Enemy.Parent = workspace.Enemies
15    local currentPivot = randomSpawn:GetPivot()
View all 28 lines...

1 answer

Log in to vote
0
Answered by 2 years ago

Round1() has its own while wait() do loop. When you run Round1() on line 27 it will continue forever because the loop on lines 17 to 21 will never stop.

0
How would i fix it then? KoalaKo_XD 27 — 2y
0
Replace it with a loop that waits for something like a "repeat until" or a loop with a certain amount of loops virushunter9 943 — 2y
Ad

Answer this question