I need to make the mouse ignore the players gun and fake arms in my FPS game i'm making and the mouse.Hit.p is vital to the gun Its used for position the gun up and down on the Y-Axis to point at the mouse and also gets the coordinates of were the bullet will fly too, please help! thanks
Also the script is running in a local script, and is not in a tool i'm using the GetMouse() function
The Hit
property of a mouse ignores any descendants of the player's Character.
Sometimes that may not be the best option, in which case you could use raycasting, probably the FindPartOnRayWithIgnoreList method.
It could look like this:
local from = workspace.CurrentCamera.CoordinateFrame.p local to = mouse.Hit.p local ignore = { --[[whichever parts you want]] , player.Character } local ray = Ray.new( from, (to - from).unit * 1000) local newTarget, newHit = workspace:FindPartOnRayWithIgnoreList( ray, ignore )
For anybody looking at this question three years later like me. You can use the following method.
Target Filter
If set, the TargetFilter and its descendants will be ignored when determining which part the mouse is pointing to.
From the Roblox Wiki
Here is a crude example.
-- Get the mouse local Mouse = game:GetService("Players").LocalPlayer:GetMouse() -- Make a part local part = Instance.new("Part", workspace) Mouse.TargetFilter = part -- You can also get parts directly from the workspace with "game.Workspace.part" or "workspace.part"
Anyways, you can read up on it a bit here:
If you liked my answer you have my humble permission to upvote. (just kidding... do what you want!)
And also, for more Roblox answers you can follow me on Twitch and YouTube