How to see if a player stopped touching something

I don’t want to use part.Touched, I want hum.Touched. I tried using TouchEnded but it doesn’t work for humanoids. What should I do? I also want it to be TouchEnded for a SPECIFIC part too, not just stopped touching anything.

1 Like

Why do you want to use hum.touched?

You can’t directly use Humanoid.Touched or Humanoid.TouchEnded events to detect when a player stops touching a specific part. However, you can achieve this by using some scripting techniques. Just put this script into the part you want.

local part = script.Parent  -- Reference to the part you want to track

local function onTouched(hit)
    local character = hit.Parent
    local player = game.Players:GetPlayerFromCharacter(character)
    
    if player then
        -- Player touched the part
        print(player.Name .. " started touching the part")
        
        local function onTouchEnded(otherPart)
            if otherPart.Parent == character then
                -- Player stopped touching the part
                print(player.Name .. " stopped touching the part")
            end
        end
        
        character.Humanoid.Touched:Connect(onTouchEnded)
    end
end

part.Touched:Connect(onTouched)

1 Like

You can also check if the two parts are touching, and when they stop you break the loop and run your code.

This is a bit hard to do … once the player stops moving the code will take it as they are not in contact anymore. Even if they are standing on the part fully touching it.

You can come up with many ways of doing this. Table, regon3, magnitude, proxy …
All logic falls apart with the way touch works in the first place. A shudder step across the part will fire touched not touched over and over. I ran into this a while back and never did figure it out totally …
I went with:

humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
	rs.Stepped:Wait()
	if (humanoid.FloorMaterial) == Enum.Material.Limestone then
-- touching    
    else
-- not touching
    end
end)

This isn’t going to work in all cases.