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.