How to use ClickDetector through invisible barrier?

I have a barrier in my game (as to keep non-participating players out) and have ClickDetectors set up on each chair that allows participating players to click on them.

It works, however, if the player’s camera is too far (and out of the barrier) then the player is unable to click on those ClickDetectors.

Here is what the barrier looks like:

And here is what I want the Server to do:

clickDetector.MouseHoverEnter:Connect(function(player)
    print("BLAH");
    -- do stuff
end)

I also have a TargetFilter for the Local Player’s mouse as to filter out that barrier, however, that still doesn’t work:

local Players = game:GetService("Players");
local player = Players:LocalPlayer;
local mouse = player:GetMouse();
mouse.TargetFilter = workspace.Objects.Barriers.Barrier;

Any tips?

1 Like

Hmm I’m not sure I don’t think a cursor can go beyond a part but I may be incorrect

That’s what I’ve been thinking too. Usually TargetFilter works great for ignoring parts, but I don’t think it works when you’re pressing a ClickDetector on the other side of that part. :confused:

Adding this will need you to add script in starterplayerscripts so the clickdetector is disabled if youre out.

My script is in StarterPlayerScripts though.

Perhaps making it so if the player is participating, set the parent of the barrier to nil on the client, then re-parenting it when they are no longer participating.

I thought about that, too, but then I have some modes where they can fight each other with knives/guns. I don’t want them to run out of the boundary. :confused:

Are you making your game based off of Breaking Point? Well, if so then you can have outer barriers that appear when clicking is not required (for the fighting parts I would assume), then are removed when it is required.

You should use raycast and whitelist the chairs.