Why isn't the function connecting?

Why isn’t the event triggering? I have the correct Instances, and Events, and no errors appear in the output.

local item = script.Parent
local clickDetector = item.ClickDetector
local selectionBox = item.SelectionBox

clickDetector.MouseHoverEnter:Connect(function()
	selectionBox.Visible = true
	print("Did I do it correctly? The value is "..selectionBox.Visible..".")
end)
clickDetector.MouseHoverLeave:Connect(function()
	selectionBox.Visible = false
	print("Did I do it correctly? The value is "..selectionBox.Visible..".")
end)

The output also doesn’t print, It’s a local script, and The Mouse icon changes.

Where is the script located?, is it a local or regular script?

It’s a local script. I’ll edit the OP.

Try this…

Code
script.Parent.ClickDetector.MouseHoverEnter:Connect(function()
    	script.Parent.SelectionBox.Visible = true
    	print("Did I do it correctly? The value is "..selectionBox.Visible..".")
    end)
    script.Parent.ClickDetector.MouseHoverLeave:Connect(function()
    	script.Parent.SelectionBox.Visible = false
    	print("Did I do it correctly? The value is "..selectionBox.Visible..".")
    end)

It gives the same results as the original script: It doesn’t work…

where is the localscript placed

Can you give me some screenshots of explorer?

Switch it to a script and parent it under the click detector.

If I believe correctly, extra additions are needed to use click detector functions on the client.

1 Like

Not even code from roblox dev api works, i think this might be bug.

This for one is not a bug and can be fixed by switching the local script to a script. I know this from prior experience with click detectors and functions. The api works completely fine when used by the server.

Yes, but it should also work for local scripts
image
But i can confirm it works as server script…
Also i noticed even if you have error in local script it doesn’t log that error (but it does on server). It looks like it’s completly ignoring local script

Server script

Server script prints error

Local script

However Local script doesn’t

where is the localscript even placed?

Same as server script
image
They are disabled beacuse i’m testing something else on same place

i looked at this LocalScript | Documentation - Roblox Creator Hub and it didnt say it worked in a clickdetector i think

However, the script I have is under a part, which means it can run code.

1 Like

but doesnt it say this?
A LocalScript will only run Lua code if it is a descendant of one of the following objects:

  • A Player’s Backpack , such as a child of a Tool
  • A Player’s character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts .
  • The ReplicatedFirst service
1 Like

I’ve tested a localscript in a part before, to test network ownership, and that’s wrong. It can run code under parts too.

Those are the wrong events for the ClickDetector, the right ones are in the script.

My bad, hope you can find help, thank you.

1 Like