Detect touch and when you don't touch a part

I’m trying to make a block that detects when you’re touching it and when you’re not touching it but I don’t know how to do it.

Script (Bad script)

local touched = false

function TouchPart()
	if not touched then
		touched = true
        print("Ouch you touch me")
	end
	
	if  touched then
		touched = false
        print("You're not touching me!")

	end

	
	
end

part.Touched:Connect(TouchPart)

https://developer.roblox.com/en-us/api-reference/event/BasePart/TouchEnded

Is the antithesis of the .Touched event.

local part = script.Parent

local function onTouched(hit)
	print("Touched!")
end

local function onTouchEnded(hit)
	print("Touch ended!")
end

part.Touched:Connect(onTouched)
part.TouchEnded:Connect(onTouchEnded)

This would be a server script inside some BasePart instance.