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

2 comments
Everything works, except for line 17-Attempt to index nil with 'Character' how can I fix this?
Well, if this is a server script you can't get the local player