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
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
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.
2 comments
just handle the error. if tppart is not there, just use workspace:WaitForChild('tppart')
You can also wrap it in a pcall() if you wish!