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?
while true do -- this loop is inside of another loop local Gems = ClonedMap.Gems local player = game.Players.LocalPlayer if not Gems:FindFirstChild("Gem") then -- This is supposed to check if there are any items (gems) in the folder wait(1) Status.Value = "All gems have been found, game over!" wait(1) player.Character:BreakJoints() -- Resets players when all gems are found, this part also doesn't work ClonedMap:Destroy() -- Resets the map break end end
You could try making a variable that the while true do runs on, for example:
local gemsFound = false while not gemsFound do -- this loop is inside of another loop local Gems = ClonedMap.Gems local player = game.Players.LocalPlayer if not Gems:FindFirstChild("Gem") then -- This is supposed to check if there are any items (gems) in the folder wait(1) Status.Value = "All gems have been found, game over!" wait(1) player.Character:BreakJoints() -- Resets players when all gems are found, this part also doesn't work ClonedMap:Destroy() -- Resets the map gemsFound = true end end