Clicking through a part

Hey I was wondering if it is possible to make a part kind of click through in a way, I have a part which is essentially a decoration and is sometimes invisible, and when it is, I want it to be like click through, I know i can easily just move the part or something like that but if theres any simpler way please let me know, thanks.

4 Likes

You could yeah, but not with usage of click detectors. You’d have to set mouse’s target filter to the part you’re hovering over and implement mouse.Button1Down event. Lastly just get the object by doing this local part = mouse.Target.

When it is invisible, perhaps disable CanCollide.

This way, you can still use a ClickDetector which simplifies things.

Basic ClickDetector Usage:

local Detector = script.Parent:WaitForChild("ClickDetector")

function onClicked(Player)
     print(Player.name.." clicked on the ClickDetector!")
end

Detector.MouseClick:Connect(onClicked)

Yes thats what i am currently doing, I do not really understand what you are trying to say but i already have it when the player clicks it checks mouse.target

1 Like

Yeah so now all you have to do is set mouse.TargetFilter to object that’s covering it.

2 Likes

But even if it is cancollide off, it still will have a object body and wont be click through.

1 Like

Oh, so what would i do? Not sure how i would implement that in a code. And just to be clear that would make the object click through correct?

1 Like

Okay so let’s say you’ve got part1 and part2. So now you want to click part1, but part2 is in the way so you can’t. What you have to do is mouse.TargetFilter = part2 at the top of your code and your mouse will act like there’s no part2 if you know what I mean.

5 Likes

Ah i see, and i am also trying to make the player not see their character, but not have there mouse locked, i can easily make their character invisible and everything, but then u wouldn’t be able to click anything through since the players limbs are still there, could i do the same thing?

I’m not sure what exactly do you mean, but yes you can make mouse ignore character’s body parts.

1 Like

Alright, thanks. But basically i want them to be like zoomed in, but not have their mouse locked in center so they can still click stuff etc.

Oh and can i toggle the mouse.Filter thing on and off?

In first person I don’t think you can unlock the mouse but just in case I’m wrong that’s how you do it

UserInputService.MouseBehavior = Enum.MouseBehavior.Default

And yes, you do that by simply setting mouse.TargetFilter to nil

Alright thanks, and yeah i don’t think its possible to unlock it, but thats why Im not putting the player in first person, rather putting the camera min and max close enough so its as if they were in 1st person, but can still move their mouse freely.

Yeah you could implement some sort of custom “shift lock”, make the character invisible and set max and min zoom distance to something that won’t lock you in the fp.

Yep, and sorry i forgot to set Solution lol

No problem, I’m glad to help you!

Hey one question, is it possible to have multiple click through parts?

Ex:

mouse.TargetFilter = part1
mouse.TargetFilter = part2

Nah, that’d first set it to part1 and then part2 right after, so it’d only ignore part2.

Ohh thats why it didn’t work, well how would i set multiple parts?