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.
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
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