Unable to click a transparent part

I didn’t know if i should put my issue here or on script support, but here is my issue.

I have a folder with inside parts and a clickDetector, one of my part has its transparency set to 0, and when i am clicking it, it’s not triggering the click event.
I checked “in game” by manually changing transparency and when it’s above 0.95 it stop working.
I read the documentation of both ClickDetector and Transparency property, and i didn’t see anything that could explain, except that “a value of 1 is completely invisible (not rendered at all).”. So i imagine if the part isn’t rendered ClickDetector can’t work.

But i really don’t know why it’s happening or how to fix it, it may seem stupid to want click an invisible part but i need a way to be able to detect when a specific “Area” is clicked. And if there is another way to do it i’ll take it to.

3 Likes

You will need to do a raycast then, as they are far more customizable. You can have one detect parts under the cursor like so:

local AreaRayFilter = RaycastParams.new()
AreaRayFilter.FilterType = Enum.RaycastFilterType.Include
AreaRayFilter.FilterDescendantsInstances = {TheFolderOfPartsYouWantToDetect}

local function GetPartUnderCursor()
    local MousePosition = UserInputService:GetMouseLocation()
    local UnitRay = Camera:ViewportPointToRay(MousePosition.X, MousePosition.Y)
    
    local RayResult = workspace:Raycast(
        UnitRay.Origin,
        UnitRay.Direction * 20 -- it will check for parts up to 20 studs away
        AreaRayFilter
    )
    
    if RayResult then
        return RayResult.Instance
    end
end
2 Likes

Thanks a lot, that’s what I end up doing and it worked perfectly ^^.

If you want the details of what’s specifically going on read this thread:

2 Likes

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