Allow Mouse.TargetFilter to be a table

As a roblox developer, making projectiles is a pain in the butt. This first step would to be to get the position of the player’s mouse in CFrame form, which can be accomplished with Mouse.Hit. Great! However, what if you want objects to be ignored? Mouse.TargetFilter! It’s great!

This is where my problem arises: MOUSE.TARGETFILTER CAN ONLY BE ONE INSTANCE! I get it. It’s deprecated. But why? I know you can raycast to get the same result, but that’s also a hassle and can be fixed with this suggestion:

Here’s my request, for all my projectile-making-homies out there: Allow Mouse.TargetFilter to be a table. I will now list the use cases:

  • Allowing devs to add debris and characters to the filter in real time! Reparenting characters and debris to a massive model is a no-go.
mouse = game.Players.LocalPlayer:GetMouse()
game:GetService('RunService'):BindToRenderStep('AlexBro', Enum.RenderPriority.Last.Value + 1, function()
	local newFilter = {workspace.ThisPart, workspace.ThatPart}
	for i, v in pairs(game.Players:GetPlayers()) do
		if v.Character and v ~= game.Players.LocalPlayer then
			table.insert(newFilter, v.Character) -- add their character to the ignore filter
		end
	end
	
	-- WOW! THE TARGET FILTER IS A TABLE!
	mouse.TargetFilter = newFilter
end)
  • Allowing multiple instances to be filtered without a model. :grin:
  • Saving developers from using more of the device’s resources making raycasts when its ALREADY BEING DONE INTERNALLY WITH MOUSE.HIT
  • Saving developers blood, sweat, and tears

Thank u devrel/people on the forum for reading my post :pray:

P.S. Look, even big man merely wanted this…
image

19 Likes

I’ve been receiving confused comments from forumers saying things along the lines of:

I’m simply suggesting that the feature would accept both instances AND tables, so that the feature can still support games that are not updated.

It’s not just TargetFilter but the whole mouse object is superseded by ContextActionService and UserInputService respectively. I think you should just raycast or explain why it isn’t able to solve your use case. Why is it a hassle to raycast? Could raycasting be improved instead of relying on legacy/deprecated API members to accomplish what you want? Things like that should be covered.

Raycasting is very inexpensive to perform and it covers most of the use cases you want already so I think personally it’d be better for you to do that than to expect Roblox to update a superseded item that exists purely for backwards compatibility. You aren’t realistically going to cast enough times that device resource become a problem (unless you’re casting thousands of long rays per frame).

Also worth nothing: been requested several times in the past before, might’ve been better to have added onto one of these threads instead.

7 Likes

Mouse is deprecated, so I doubt they’ll listen to this feature request.

2 Likes