The script I made is supposed to detect when there are no more items in a folder, its in a while true do loop. But the loop completely restarts and doesn't do anything when all the items are collected. Whats wrong?
01 | while true do -- this loop is inside of another loop |
02 | local Gems = ClonedMap.Gems |
03 |
04 | local player = game.Players.LocalPlayer |
05 |
06 | if not Gems:FindFirstChild( "Gem" ) then -- This is supposed to check if there are any items (gems) in the folder |
07 |
08 | wait( 1 ) |
09 |
10 | Status.Value = "All gems have been found, game over!" |
11 |
12 | wait( 1 ) |
13 |
14 |
15 | player.Character:BreakJoints() -- Resets players when all gems are found, this part also doesn't work |
You could try making a variable that the while true do runs on, for example:
01 | local gemsFound = false |
02 |
03 | while not gemsFound do -- this loop is inside of another loop |
04 | local Gems = ClonedMap.Gems |
05 |
06 | local player = game.Players.LocalPlayer |
07 |
08 | if not Gems:FindFirstChild( "Gem" ) then -- This is supposed to check if there are any items (gems) in the folder |
09 |
10 | wait( 1 ) |
11 |
12 | Status.Value = "All gems have been found, game over!" |
13 |
14 | wait( 1 ) |
15 |