Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I fix Click Detectors if Filtering is Enabled?

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

2 comments

0

You could use a local script in StarterGui to execute your script or use the Touched event.

0

Touched won't work in this case... How would I use a localscript for this?

2 answers

✓ Accepted answer

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.

1 comment

0

I'll try this when I get the chance. Thx!

This discussion is preserved as it was. New answers, comments, and votes are closed.