:L I don't do that many videos? I guess you mean either my acertainblockgamethatisn'troblox lts plays which were CURSED. Every single video had something going wrong- One didn't upload, one had no sound, one had no color if I remember, and one had the first 10 or so minutes cut off. :L
Or my roblox scripting tutorials?
Eh, here's an example of pcall. I'd advise making it use a GUI instead of a message though.
pcall simply lets a chunk of script run, and if it errors, it skips the rest of the code in pcall and carries on.
xpcall is what you want; it has the same functionality, but as the second argument, you pass in a function, and when it errors, it'll call that function with the error string, so for example:
function displayError(errorText)
local a=Instance.new("Message",Workspace)
a.Text = errorText
game:GetService("Debris"):AddItem(a,5) -- Deletes a after 5 seconds.
end
xpcall(function()
lulz --Going to error.
end, displayError) |