Overhead UI Glitching Whilst Touching Part

I have a script that makes an overhead UI appear above a players head once they touch a part, however, whenever the player walks around on the part, the UI starts glitching and disappearing then re-appearing. I have attached a video below of the issue:

The script inside of the part is below:

local Debris = game:GetService("Debris")

local OverHead = game.ServerStorage.RedOverhead
local TouchPart = script.Parent

local function Touched(TouchingObject)
	local Character = TouchingObject.Parent

	if not Character:FindFirstChild("Humanoid") or Character.Head:FindFirstChild(OverHead.Name) then return end

	local OverheadClone = OverHead:Clone()
	OverheadClone.Parent = Character.Head
end

local function TouchEnded(TouchingObject)
	local Character = TouchingObject.Parent

	if not Character:FindFirstChild("Humanoid") then return end

	local FoundOverHead = Character.Head:FindFirstChild(OverHead.Name)
	if FoundOverHead then
		Debris:AddItem(FoundOverHead, 0)
	end
end

TouchPart.TouchEnded:Connect(TouchEnded)
TouchPart.Touched:Connect(Touched)

The part is anchored and CanCollide is set to “False”, any help would be appreciated, thanks.

i’ve had this problem a bit before, basically TouchEnded also fires right after Touch regardless if you’re still in the part or not. You could use some code upon TouchEnded to check if the player is still touching the part and only if they’re not remove the ui. You could use WorldRoot:GetPartBoundsInBox()

Any example or advice on how I would implement/use that within the script?

I think instead of GetPartBoundsInBox, you could try using GetPartsInPart(), you pass in the part to act as your zone and it’ll return to you what parts are currently touching the part as a table, then you go through the table and check if the player is still in the part and if they are, keep the UI or else remove the UI

Alternatively, if you prefer a simpler approach that doesn’t require programming everything yourself, you could try using ZonePlus, a module made by ForeverHD to create zones easily