Apparently ClickDetectors don't work if filtering is enabled in workspace. Any workaround?
Yes, ClickDetectors
are not compatible with FilteringEnabled. So you have to find an alternative method.
One way you could do this is to have a localscript in somewhere that replicates to the client(e.g. StarterGui, StarterPack) and have a Button1Down
event, so when the player clicks.. you can compare the mouse.Target
with the wanted instance. If they match then excecute your code(:
--Define player local plr = game.Players.LocalPlayer --Get their mouse local mouse = plr:GetMouse() --Define the part to click local part = workspace.Part --When they click mouse.Button1Down:connect(function() --Get the target local targ = mouse.Target --Compare the target with the part to click if targ == part then --Code end end)
(EDIT)
If you wanna be fancy with it then you can change the mouse.Icon
while the mouse.Target
is focused on your wanted part. This should be done with the mouse.Move
event, rather than a while
loop, for the most effective and efficient results.
local template = 'rbxassetid://' --The template local detected = '000000000' --Icon when over part. local default = '' --Default Icon --When the mouse moves mouse.Move:connect(function() --Get the target local targ = mouse.Target --Compare the target if targ == part then --If they match, change the icon mouse.Icon = template..detected else --Otherwise, reset it. mouse.Icon = default end end)
(EDIT)
Additionally, if you tend to have a lot of things you want to click then you can either check if the mouse.Target
has a ClickDetector in them(so you'd have to place a clickdetector in whatever you want to click) or you can check if the mouse.Target's name matches something.
Filtering Enabled Clickdetector Model
Here's a model I made that allows you to use clickdetectors in FE. It is based off of your mouse clicks rather than the clickdetector being triggered.