Highlight in script is not working as should

I am recently making a game and I want when the player clicks on a object it highlights it and it works perfectly, except the fact that the same object just another one somewhere else also highlights at the same time meaning 2 objects highlight at the same time and I can’t figure out why.

A tiny part of the script where I use the highlight.(btw this is a gun)

				if Raycast then
				local Hit:Part = Raycast.Instance
				print(Raycast.Instance.Name)
					local boleen = Hit:FindFirstChild("ADestructable") 
				local Hp = Hit:FindFirstChild("HP")
				local Fx = Hit:FindFirstChild("FX")
				local Highlight = Hit:FindFirstChild("Highlight")
					
					
						if Hp.Value > 0 then
							dead = false
					Hp.Value = Hp.Value - 5
					Fx.Enabled = true
					Highlight.Enabled = true
					script["HitMarker Sound Effect"]:Play()
					wait(0.5)
					Fx.Enabled = false
					wait(0.5)
					Highlight.Enabled = false

							if Hp.Value <= 1 then
								if dead == false then
									script["arsenal kill sound"]:Play()
									script["Kill sound"]:Play()	
									kills.Value = kills.Value + 1
									dead = true
									end
								end
							end
						end
					end
				end)
	end



1 Like