Hello fellow devs! I have a fairly simple question this fine, fine evening.
I know in JavaScript, you can use the
return;
command to restart a for loop, etc.
I was wondering how I could do that with Lua.
My Code (The issue):
-- This is wrapped in a bigger for loop. if (Part:IsA("Part")) == false or Part.Name == "Solid" then print("Removed".. Part.Name) break -- I have also tried "return". end
Full code:
local Model = script.Parent wait(5) for Model, Part in pairs(Model:GetChildren()) do print(Part.Name) if (Part:IsA("Part")) == false or Part.Name == "Solid" then print("Removed".. Part.Name) break end if Part.Shape == Enum.PartType.Block then game.Workspace.Terrain:FillBlock(Part.CFrame, Part.Size, Enum.Material.Mud) elseif Part.Shape == Enum.PartType.Cylinder then elseif Part.Shape == Enum.PartType.Ball then game.Workspace.Terrain:FillBall(Part.Position, Part.Size.X/2, Enum.Material.Air) end Part:Destroy() wait() end
I'm either looking for another scriptinghelpers/DevForum link or an example.
Thanks in advance, Tim
local Model = script.Parent wait(5) function check(p) if not p:IsA("BasePart") or p.Name == "Solid" then print("Removed".. Part.Name) return true end end for Model, Part in pairs(Model:GetChildren()) do print(Part.Name) local checkstuff = check(Part) if checkstuff then return end if Part.Shape == Enum.PartType.Block then game.Workspace.Terrain:FillBlock(Part.CFrame, Part.Size, Enum.Material.Mud) elseif Part.Shape == Enum.PartType.Cylinder then elseif Part.Shape == Enum.PartType.Ball then game.Workspace.Terrain:FillBall(Part.Position, Part.Size.X/2, Enum.Material.Air) end Part:Destroy() wait() end
explanation was included in chat when this answer was provided.