Doesn't print when I'm "NOT" touching the part

Im currently trying to print out “Currently not hitting part” when a player is not hitting the part, but right now it only prints “print(“hitting part”)” but when im not touching the part it dosen’t print anything :), anyone know the solution to my problem?

workspace.Shop.HitBox.Touched:Connect(function(hitbox)
    if hitbox.Parent:FindFirstChild("Humanoid") then
        local plr = game.Players:GetPlayerFromCharacter(hitbox.Parent)
        if plr then
           print("hitting part")
        else
            print("Currently not hitting part")
        end
    end
end)

Thanks!

Add an event BasePart | Roblox Creator Documentation for when a player stops touching the part. The touched event only fires when something touches the part.

1 Like

You’re checking for a Humanoid. A humanoid will only be there if a player is touching it. Get rid of

if hitbox.Parent:FindFirstChild("Humanoid") then

You can do

if hitbox.Parent:FindFirstChild("Humanoid") then
	print("hitting part")
else
	print("Currently not hitting part")
end
1 Like