Click Detector events not firing locally

I have this local script here that would make a highlight around a part when the mouse enters, and delete it when the mouse leaves, but it is not working. I put the same exact script into a server script and it worked, but I don’t want the highlight visible on the server. Is there any way to do this in a local script? any help is appreciated. Thanks.

script.Parent.ClickDetector.MouseHoverEnter:Connect(function()
	local Highlight = Instance.new("Highlight",script.Parent)
	Highlight.FillTransparency = 1
	Highlight.DepthMode = "Occluded"
end)
script.Parent.ClickDetector.MouseHoverLeave:Connect(function()
	script.Parent:WaitForChild("Highlight"):Destroy()
end)

1 Like

because localscripts dont run in workspace, parent the localscript to localplayerscripts and change script.Parent to the full path of the clickdetector

2 Likes

It works. Thanks for the help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.