Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
sonuka 24
5 years ago
Edited 5 years ago

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
0
just handle the error. if tppart is not there, just use workspace:WaitForChild('tppart') Fifkee 2017 — 5y
0
You can also wrap it in a pcall() if you wish! Afterl1ght 321 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
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

Ad

Answer this question