Script Not Stopping on Error

How can I make a script not stop when there’s an error?

1 Like

Simply use a pcall. Thats mainly why we use pcalls.

Example:

local success,error = pcall(function()
      --stuff here
end)
clone.ProductImage.Image = "rbxassetid://" + tostring(v:GetAttribute("image"))

How do I make setting an ImageLabel’s Image into a pcall?

Try this:


local success,error = pcall(function()
      clone.ProductImage.Image = ....
end)

Personally you shouldn’t use pcalls that often I believe especially for things you can check yourself. For the piece of code you gave you can simply do:

if v:GetAttribute("image") then
   clone.ProductImage.Image = "rbxassetid://"..tostring(v:GetAttribute("image"))
else
  -- Doesn't exist
end
1 Like

Definitely don’t use pcall. Errors are a good thing. Pcall should only be used if the problem is out of your control, such as with HttpService.

1 Like