I want to get the model of what I click, so I have two buildings, one called mainbase and the other called farm, both a group and a primary part inside. When I click the mainbase it shows I clicked the mainbase model, but when I click the farm my clicks go through the building entirely and the click gets the floor below it
As you can see in this image, when i click on my mainbase and it shows it
But in this image when i click on my farm and it doesnt show it
Hierarchy of both
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local isinteracting = false
mouse.Button1Down:Connect(function()
if not isinteracting then
local target = mouse.Target
local model:Model = target:FindFirstAncestorOfClass("Model") or nil
print(model)
end
end)
mouse.Button2Down:Connect(function()
end)