Collision problem: Player can collide with a hole

Hi,
I want to run a script only when the player touches the gray part of the object shown, but the whole object is not only the solid part, but the hole too. See the following image for reference:

Any clue on how to do this? - This probably won’t be of help, but here is my code:

script.Parent.Parent.Touched:Connect(function(Hit)
        print("ah")
        if PlayerGUI:FindFirstChild("Shop") then
                Debris:AddItem(ClonedGUI, 2)
                ClonedGUI.Settings:TweenPosition(UDim2.new(0.25, 0, 1.5, 0), "In", "Back", 1, false)
        end
end)

Thanks in advance hehe ^ ^

The collision is just not accurate, to get more accurate collision you must set the part’s CollisionFidelity to Precise blah blah blah, anyways it starts with precise.

1 Like

It’s not a problem with collision fidelity. Rather, the cube is modelled so the hole in the cube is touchable. In fact, I already tried to use the precise collision and it didn’t work. That’s what the print("ah") part on my code is for.

Could you possibly send me a picture of the model so I can understand?


1 Like

So, if I understand correctly, the whole mesh is able to collide but you only want to execute your code if the player touches the gray part which is not possible since the hole also fires .Touched, is that right?

1 Like

Yes, that’s what I meantㅤㅤㅤㅤㅤㅤㅤㅤ

Well then I would suggest using 1 union and 1 cylinder to achieve this.

Make a cube and a cylinder as shown in the picture, then you can make a union after negating the cylinder.

This union mesh will be the one you connect to the .Touched event, after doing so make another cylinder with same size than before and make it transparent to create the hole collisions.
image

That would be it.
Also don’t forget to weld those up and then set the cylinder CanTouch property to false.

1 Like

Actually you could also just use another cube for making the hole collisions since that would save up some extra triangles for the renderer. (About 80 tris)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.