mouse.Target not picking up parts

mouse.Button1Down:connect(function()
	if var.deleting then
		local target = mouse.Target
		if target then
			print(target, target.Parent, target.Parent.Parent)
			local targetBase = target.Parent.Parent.Parent
			if targetBase then
				if targetBase == playersPlot then
					print(4)
					if target.Parent.PrimaryPart.Name == 'HitBox' then
						print('Destroying ', target.Parent.Name)
					end
				end
			end
		end
	    wait(0.5)
    end
end)

The script nevers gets passed if targetBase == playersPlot then so decided to find out what exactly the target and all its parents were.

So when I click on this wall, it apparently can’t see it, so it picks up the stuff behind it I guess? The first print (target) prints Base (which is the grass with the grids on it) even though I am clicking on this wall (so it should be printing Wall)

I thought this may have something to do with FE?? But I checked in a server test, and the wall is being placed on both the server and the client. So not sure why the client ain’t picking up that it is there?

Is

if var.deleting then

influcing your code? (Have you printed before doing the check)

Sidenote

When wanting to find an object’s class when debugging I find the Instance:GetFullName() function extremely helpful

Other than that, I would try copying the map you have and placing it inside a Baseplate with no scripts, then trying mouse.Target there to see if it will work. If it isn’t printing then there may be a bigger issue, but if it is then the issue is isolated down to your place and scripts.

I don’t see how it would affect this is anyway. To my understanding, mouse.Target should return the part I am clicking in. And since I am clicking on a part called ‘Wall’ I’d think it’d return Wall. I don’t know how it is getting Base. When I put stuff behind the wall and test, it prints the stuff behind the wall. But no matter where I click on the wall, it never returns Wall

I was trying to see if it was actually an issue with the part, and if the issue was reproducable. Are the parts that do print behind the concerned part parts created on the client or parts created on the server.

I would still try copying the concerned part to a baseplate to see if it is something that is affected by scripts

The parts behind the wall are all created from studio, so they are already in the game. The wall is placed by the client, but it is replicated to the server as well. So the wall is visible in the server and client

Perhaps that is the issue. I’m not sure why that is being caused however. I will do some testing in a Baseplate to confirm if that’s the issue

I have attached a .rbxl baseplate file which has a LocalScript under StarterPlayer which creates a part locally and parents it to Workspace. I have no issue whatsoever and I even tried changing the transparency of the part.

Where exactly are you parenting the concerned part?
NinjoOnline.rbxl (13.0 KB)

Assuming that you are using a local script for your placement system, replication is not the issue. While server scripts cannot see client created objects, local scripts can.

It seems like the part is being ignored, that could happen because an ancestor of the part is in a mouse ignore list.
Make sure that the target is not a descendant of the player’s character. And check that its not descendant of the mouse TargetFilter, you can set the target filter to nil to check if that’s the problem.
Mouse.TargetFilter = nil

2 Likes