Model not found on click

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)

Look at what target is set to in that connection function. Might be something overlapping with the farm building.

Figured it out, when I purchase the building, on the server side i was setting everything in it’s canquery to false, which i just changed to true

1 line edit to fix a 6-8 hour issue

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