Trouble with detecting when someone clicks their character

So, I want to detect when someone clicks their character with their mouse. The trouble is, Mouse.Target apparently ignores your character, since when I click my character, Mouse.Target equals the thing behind me, like I’m clicking through myself.

I’ve tried using a click detector, but apparently that also doesn’t function if it’s in your character.

Your Character is ignored from the Mouse.Target and ClickDetectors, the only time you can click on your body I believe is when you are sitting in a VehicleSeat.

So there is no way around that?

You could try welding an Invisible part to the character that is not parented to the Character model.

1 Like

Does setting mouse.TargetFilter to nil help? If not, and even if it does, I personally just recommend using a custom solution. The mouse is legacy anyway.

local UserInputService = game:GetService("UserInputService")
local Workspace = game:GetService("Workspace")

local camera = Workspace.CurrentCamera

local function get_target(params: RaycastParams?): Instance?
	local mouse_location = UserInputService:GetMouseLocation()
	local ray = camera:ViewportPointToRay(mouse_location.X, mouse_location.Y)
	local result = Workspace:Raycast(ray.Origin, ray.Direction*1000, params)
	
	return result and result.Instance
end
1 Like