I made a Round Script. It works well, but at the end of the round, studio would freeze and timeout the script. I tried many things, different posts, but they didn’t work, and I have wait() in the script. Help is appreciated!
repeat
timer -= 1
Status.Value = "Round starting in "..timer
wait(1)
until timer == 0
local PartToDelete
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(time_between_destroy)
PartToDelete:Destroy()
else
repeat
PartToDelete = ChildrenOfModel[math.random(#ChildrenOfModel)]
if PartToDelete.Name == "LandPart" then
PartToDelete.Material = Enum.Material.Neon
PartToDelete.BrickColor = BrickColor.new("Really red")
wait(time_between_destroy)
PartToDelete:Destroy()
end
until PartToDelete.Name == "LandPart"
end
end
for i, v in pairs(plrstable) do
print(v)
end
end
In the repeat loop your only using a wait if the partname is landpart, so if you dont have landpart in the table itll just break the repeat until loop.