How to stop Error Spam

Hey all,
I have a simple lava script
image
And whenever something that doesn’t have a humanoid touches it, I get this


I get about 3 every .5 seconds

How do I fix the error spam? I tried

if Humanoid then

but it yields the same results :frowning:

script.Parent.Touched:Connect(function(Hit) --! On touch something, this is fired.
    if Hit.Parent and Hit.Parent:FindFirstChild("Humanoid") then --! We check if the object that touched the thing, is a player or no.
        local Humanoid = Hit.Parent:WaitForChild("Humanoid"); --! Humanoid for Character.
        Humanoid:TakeDamage(100) --! Kills the player.
    end
end)
2 Likes

You should probably be using collection service for this but whatever

script.Parent.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
    if humanoid then
        humanoid.Health = 0
    end
end)
1 Like

yeah sorry im newer to scripting, so its kinda basic

CollectionService works when you’re going to work with a lot of parts, for example, different parts that when you touch them, you get 1, 2, or 3 points. CollectionService will store all of them in a folder, and you will have to call the function .Touched 1 single time.