Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make an error inside not break a loop and continue it?

How would I make a loop continue even if it errors?

while wait() do
local p = Instance.new(“Part”,workspace)
p.CFrame = workspace.tppart.workspace -- say tppart is not there and this line error how do i make the loop continue going?
end

2 comments

0

just handle the error. if tppart is not there, just use workspace:WaitForChild('tppart')

0

You can also wrap it in a pcall() if you wish!

1 answer

while wait() do
     local success, err = pcall(function()
           local p = Instance.new(“Part”,workspace)
           p.CFrame = workspace.tppart.workspace -- say tppart is not there and this line error how    do i make the loop continue going?
     end)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.