How do I make errors Inside Functions Easier to Find?

Hi there Other Developers,

sometimes when I get an error, for example: argument missing or nil, the line I clicked on sends me to the line that’s running the function (for example: newDropper()). That way I can’t really find what’s causing the error.

1 Like

You can use pcall, create the pcall inside the function and detect the error.

1 Like

quite new at scripting, but how would I use pcall?
thanks.

1 Like

Maybe like that :

function aRandomFunction()
	local success, Error = pcall(function()
		--Your functions here
	end)
	
	if success then
		print("Everything seem to work perfectly.")
	else
		warn("Error found : " ..Error)
	end
end

aRandomFunction()
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.