Script abruptly stopping

Hello!

I made a game round script, it works and stuff, but when the part deletion ends, the script just stops? I don’t know how to fix it, and I can’t find any posts. Help is appreciated!

for count = 1, #Map:GetChildren() do 
		timer = tonumber(#Map:GetChildren())
		timer -= 1
		Status.Value = "Round Time left: "..timer
		local ChildrenOfModel = Map:GetChildren()
		PartToDelete = ChildrenOfModel[math.random(#ChildrenOfModel)]
		if PartToDelete.Name == "LandPart" then
			PartToDelete.Material = Enum.Material.Neon
			PartToDelete.BrickColor = BrickColor.new("Really red")
			wait(1)
			PartToDelete:Destroy()
		else
			repeat wait()
				PartToDelete = ChildrenOfModel[math.random(#ChildrenOfModel)] 
				if PartToDelete.Name == "LandPart" then
					PartToDelete.Material = Enum.Material.Neon
					PartToDelete.BrickColor = BrickColor.new("Really red")
					wait(1)
					PartToDelete:Destroy()
				end
			until PartToDelete.Name == "LandPart"
			end -- Where I think the script stops
	end
	wait(1)
	print("script didnt stop")
end

image

try changing that to

until PartToDelete.Name == "LandPart" do
end -- Where I think the script stops

It errors because I need an end to it. The code is also in a while true do loop.

1 Like

Does the output show an error?
I think I copy the code wrong because there is one “end” too many.

so what does the script exactly do?

No errors in output, the code is in a loop.

So I’m making a round-based game, and the script controls everything, intermissions, statuses. I can paste the whole script if you want

1 Like

image

check if that part keeps looping when round ended

Nope, after the map is gone, the script just gives up and stops without any errors.

what happends if u remove that part image

does it continue the rounds or it still stops

1 Like

Yep, it works, the script didn’t end.