How can I have mouse.Target work on my own character?

I’ve made medkit system so if you hold left click on a player it heals them until you release the button or they reach max health. This only works on other players/humanoids but not my own character.

https://gyazo.com/d910b51cd60b75d42ec63a4299b2646e

The system uses mouse.Target to detect if there is a player

while task.wait(.1) do
	if equipped then


		if mouse.Target then
			if mouse.Target.Parent then
				if mouse.Target.Parent:FindFirstChildOfClass("Humanoid") then

					target = mouse.Target.Parent

					if (plr.Character.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude < 20 then
				end
			end
		end
	end
end

Any help is appreciated.

I didn’t see the code where it heals the character. Also, why not use UserInputService to do this?

1 Like

Unfortunately due to the way characters work, Mouse.Hit and Mouse.Target inherently ignore limbs. You could get around this by raycasting from the mouse position using Camera:ScreenPointToRay and UserInputService:GetMouseLocation to get the appropriate ray at the mouse position in 3D space.

2 Likes

Yep here is an example function which uses it:

1 Like

Weld an invisible massless part to your character that has no coliision and covers the character entirely. Part should be in a folder in workspace and not your character so it won’t be ignored.
I think for percision I would use this method for other characters as well since it’s hard to click on mobile.

1 Like