Can you Stop these Errors?

Example 1 : I have a script that controls a humanoid, but if and when that humanoid is deleted there is a chance that a line in the code has already ran while deletion and now that line is going to give me an error.
Example 2:
I also have the Humanoid MoveTo a position, but if the Humanoid is deleted its going to error and start a annoying error stack, what should I do to avoid these errors?

Am I supposed to make a constant check if the Humanoid model exists?

I find errors as an issue since if looking to possibly debug something else and then there are a bunch of unneccessary errors that flood the output.

1 Like

I’m pretty sure you could do something like this

local Humanoid = script.Parent:FindFirstChild("Humanoid") -- Reference location of humanoid
print(Humanoid)
if Humanoid then
	print("found")
	--Manipulate Humanoid
else
	print("Already deleted")
	--Cancels Manipulation
end

This should check if the humanoid exists without giving you any errors

I would like to know how to stop these errors.

You can check if something is nil with an if statement.
if object ~= nil then
– object exists, do stuff
else
– object does not exist, stop whatever would have caused the error
end