Weird Highlight behaviour

Hello!

I am meeting with some weird and unintended highlight behaviour:


You can notice, that upon touching, it will enable, but then disable… Also noticable, that the Enabled property is not changed.

But how can I fix that?

Is there any script changing the Highlight?

script.Parent.Parent.Attachment.BallSocketConstraint.Changed:Connect(function()
	if script.Parent.Parent.Attachment.BallSocketConstraint.Attachment1 == nil then
		script.Parent.Enabled = true
		script.Parent.Parent.Anchored = true
	else
		script.Parent.Enabled = false
		script.Parent.Parent.Anchored = false
	end
end)
script.Parent.Parent.Parent.Changed:Connect(function(Parent)
	print("Parent has changed!")
	script.Parent.Enabled = true
	script.Parent.Parent.Anchored = true
end)
while true do
	for i = 1, 20 do
		task.wait()
		script.Parent.FillTransparency -= 0.05
	end
	task.wait()
	for i = 1, 20 do
		task.wait()
		script.Parent.FillTransparency += 0.05
	end
end
script.Parent.Parent.Parent.AttachmentPoint.Touched:Connect(function(otherPart)
	if otherPart.Parent == game.Workspace["DAF XF"].Body then
		script.Parent.FillColor = Color3.fromRGB(0, 255, 0)
	end
end)
script.Parent.Parent.Parent.AttachmentPoint.TouchEnded:Connect(function(otherPart)
	if otherPart.Parent == game.Workspace["DAF XF"].Body then
		script.Parent.FillColor = Color3.fromRGB(255, 255, 255)
	end
end)

Only these I think.

What ever is making the Attachment set to nil might be the problem, else I do not really know

Quick question, why not use TweenService there?

You get smoother results in less lines, plus I believe its less laggy than that.