Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How would I fix Click Detectors if Filtering is Enabled?

Asked by
Zerio920 285 Moderation Voter
9 years ago

Apparently ClickDetectors don't work if filtering is enabled in workspace. Any workaround?

0
You could use a local script in StarterGui to execute your script or use the Touched event. Redbullusa 1580 — 9y
0
Touched won't work in this case... How would I use a localscript for this? Zerio920 285 — 9y

2 answers

Log in to vote
7
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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.

0
I'll try this when I get the chance. Thx! Zerio920 285 — 9y
Ad
Log in to vote
0
Answered by 7 years ago

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.

Answer this question