Mouse target only identifying Baseplate

I’m making a ‘Profile System’. It works by when you click on a Player.Character part a gui will appear with all their stats.

Whenever I implement something new on my game, I first test it on a blank Baseplate. When I finished the system on the baseplate - which worked perfectly fine - and imported it to my game it breaks.

Local Script:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.Button1Down:Connect(function()
local target = Mouse.Target
Print(target.Name)
If target.Parent:FindFirstChild(“Humanoid”) then
— Gui appear script
end)

ERROR: Cannot identify with “Parent”

It gets stuck on the “if target.Parent”. When I test it the target either identifies as workspace.Baseplate or nil.

Even so I still do not know why it’s throwing an error as that line is in an “if” statement so it should just output either true or false and not an error.

Thank you

That’s probably because the Mouse’s TargetFilter is automatically set to the player’s character, which makes the mouse ignore it. To fix this, you can do Mouse.TargetFilter = nil at the top of the Button1Down function, so that it ignores nothing.

Also, your if statement would error if target was nil, because you’re indexing it with Parent without checking if it exists or not. To fix this, you can do if target and target.Parent:FindFirstChild("Humanoid") and it should work, since it’ll also check if target exists.

Your print would also error on nil, since you’re indexing Name directly without checking if target exists. You can also solve this by doing: print(target and target.Name) instead.

Hope this helped

1 Like

Thanks for the reply!

I guess I didn’t go into much detail so let me expand a little bit.
What I don’t understand is if my screen looks like this:

why would Mouse.Target ever be a nil value, even though I am clicking on the wrench or the toolbox

Does it have a certain distance it can travel like a ray’s magnitude?

1 Like

For some reason I think that it’s because of the FOV, if you set it to 70(the default), does it still return nil?

1 Like

You are a freaking GENIUS my dude - All credit to @brokenVectors

Problem:
I got this Camera script that locks your Camera’s movement and also sets the fov to 1 and a lot of zoom out to give some sort of a “flat” look.

When I went to move the toolbox this happened…

Maybe because the camera is so far away (1,000+ studs) ROBLOX doesn’t get pin-point accuracy from that distance.

Solution:
Make sure your camera is not so far from what you want to be “Clickable”, you should be cautious using extreme fov’s

1 Like