FilterEnabled + Serverscript ClickDetectors dont work

Put this is a script (NOT localscript):
local c = Instance.new(“ClickDetector”,script.Parent)
c.MouseClick:connect(function()
script.Parent.BrickColor = BrickColor.Random()
end)

Put script in a brick.
Enable FilteringEnabled
Upload to roblox and you will see it doesn’t work.

I get that it doesn’t work IF it were a localscript, but this is a serversided script so I see no problem with it.

1 Like

Not really a bug because clicks do not replicate.

Can’t you raise the event locally, then use remoteevent?

not a bug blah blah blah server-client boundary blah blah blah FE is for serious people blah blah blah FE should be used by everyone blah blah blah ClickDetectors are going to be less-supported because “they’re obsolete” and “better ways” of getting user input exist blah blah blah we often spew nonsense like that last one blah blah blah everyone knows how RemoteEvents, Local Scripts, and Server Scripts work blah blah blah if you want your place streamed it has to be FE blah blah blah blah blah blah blah blah freakin blah
-ROBLOX

I dont understand :confused:

A click detector that runs on a normal script should not be affected at all by filtering?
Or do you meen that the click event does not get sent from the client?

The Click event is a input, just like when you press a Key down on your Keyboard, that is why it doesn’t replicate. Since Input should be handled on the Client side on ROBLOX. So that is why they don’t replicate.

Solution :
We also faced this in Deathrun, you only need to use a LocalScript that sends an RemoteEvent to the Server, and do your code there.

Here’s an explanation by Stravant:

[quote] Like I said, they’re not really GUI elements, but rather somewhere inbetween physical in-game elements and GUI elements. I’m just calling them GUI elements since I don’t know any good term for what they actually are.

The bottom line is they’re an element that’s concerned with the user input state that only exists on the client, just like GUIs. The server can’t know whether you’re clicking on a ClickDetector without the client explicitly telling it so. This is unlike something more “physical” like a ContextAction, where the client could tell the server that it’s “using a contextaction” and the server would still be able to guess which ContextAction the client is talking about most of the time even without the cilent explicitly telling it. This is also unlike a completely physical thing like a 3d button in the world, where the server exactly knows that you stepped on the button.

Basically there’s a spectrum of physicality of user input:
← less physical - - - - - - - - - - - - - - - - - - - - - - - more physical →
GUI Button, ClickDetector, Context Action, Physical Button [/quote]
[Source thread]

If you do not want to completely rewrite all of your current button code, which was the case when I updated Deathrun to run on FilteringEnabled, you can make them work as expected with this code:

[quote] If you just want a quick and dirty hack, this in a localscript in the backback, along with a “ClickDetectorBindable” event in ReplicatedStorage:

local function handleClickDetector(click)
click.MouseClick:connect(function()
game.ReplicatedStorage.ClickDetectorBindable:FireServer(click)
end)
end
local clickdetectors = findAllClickDetectors() -- just a simple recursive search of the workspace
for _, click in pairs(clickDetectors) do handleClickDetector(click) end
game.Workspace.DescendantAdded:connect(function(o)
if o:IsA('ClickDetector') then
handleClickDetector(o)
end
end)

And then on the server, instead of directly listenening on ClickDetectors:

game.ReplicatedStorage.ClickDetectorBindable.ServerEvent:connect(function(player, detector)
if detector == <the one you're interested in handling here> then
-- do your stuff
end
end)

Not very efficient, but it will work, and only requires minor changes to your server code (clickDetector.MouseClick:connect(… → becoming: ClickDetectorBindable.ServerEvent:connect(function(detector) if dectero == clickDetector), and no additional code on the client other than that one LocalScript in the backpack. [/quote]
[Source thread]

1 Like