FindPartOnRayWithIgnoreList With Mouse Filter Error

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to create a bomb-throwing script that allows you to ignore a table of parts that the player mouse will ignore when fetching the position of it.

  2. What is the issue? Include screenshots / videos if possible!
    I am given this error when I try to activate the tool:
    image

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried using Mouse.Filter, but I need to be able to filter out multiple instances and I cannot use a folder since the parts I’m filtering out need to be in their designated locations.

ThrowScript

--Modules--
local RS = game:GetService("ReplicatedStorage")
local itemModules = RS:WaitForChild("ItemModules")
local bombModule = require(itemModules:WaitForChild("BombModule"))

local skinsDictionary = require(RS:WaitForChild("DataModules"):WaitForChild("ShopData"):WaitForChild('SkinsDictionary'))

local checkPlayerOwnsPerk = RS:WaitForChild("CheckPlayerOwnsPerk")

local SS = game:GetService("ServerStorage")
local shopAssets = SS:WaitForChild("Assets"):WaitForChild("ShopAssets")
local effects = shopAssets:WaitForChild("Effects")
	
local Tool = script.Parent
local bombScript = Tool.Bomb

--GUI--
--local powerMeter = Tool.PowerMeter

--Animmations--
local animations = Tool.Animations
local bombIdle = animations.BombIdle
local bombCharge = animations.BombCharge
local bombReload = animations.BombReload

--Configurations--
local config = Tool.Configuration
local reloadTime = config.ReloadTime
local currentPower = config.CurrentPower
local maxPower = config.MaxPower
local minPower = config.MinPower
local hasHyperBomb = config.HasHyperBomb

local bombFireAttachment = Tool.Handle:FindFirstChild("FireAttachment")
local canThrow = true

--Bomb Stats--
local activated = false
local bombIdleTrack = nil
local chargeTrack = nil
local reloadTrack = nil


--Sounds--
local throwSound = Tool:WaitForChild("Handle"):WaitForChild("Throw")
local reloadSound = Tool:WaitForChild("Handle"):WaitForChild("Reload")
local equipSound = Tool:WaitForChild("Handle"):WaitForChild("Equip")

--Remote Functions--
local remoteFunction = Instance.new("RemoteFunction")
remoteFunction.Parent = script.Parent
remoteFunction.Name = "FetchMousePos"

script.Parent.Equipped:Wait()
local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
local targetpos = function()
	return remoteFunction:InvokeClient(plr)
end

LocalScript

local CS = game:GetService("CollectionService")
local HS = game:GetService("HapticService")
local workspaceService = game:GetService("Workspace")
local UIS = game:GetService("UserInputService")
local isVibrateSupported = HS:IsVibrationSupported(Enum.UserInputType.Gamepad1)
local largeSupported = false

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid", 120)
local hrp = char:WaitForChild("HumanoidRootPart", 120)

local currentCamera = workspaceService.CurrentCamera

local RS = game:GetService("ReplicatedStorage")
local bombModule = RS:WaitForChild("ItemModules"):WaitForChild("BombModule")
local FetchIgnoreList = bombModule:WaitForChild("FetchIgnoreList")

local RS = game:GetService("RunService")
local T = 1
local Gravity = Vector3.new(0, -workspace.Gravity, 0)

local Tool = script.Parent
local reloadTime = Tool:GetAttribute("ReloadTime")

local ignoredParts = {}

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

local function CreateIgnoredPartsList()
	if not plr then return end

	local char = plr.Character
	table.insert(ignoredParts, char)
	for _,part in pairs(char:GetDescendants()) do
		if part:IsA("BasePart") or part:IsA("Model") or part:IsA("MeshPart") or part:IsA("UnionOperation") then
			table.insert(ignoredParts, part)
		end
	end

	local fuse,plate = script.Parent:FindFirstChild("Fuse"), script.Parent:FindFirstChild("Plate")
	if fuse and plate then
		table.insert(ignoredParts, fuse)
		table.insert(ignoredParts, plate)
	end

	--Find All Pets so that players cant hit
	for _,plr in pairs(game.Players:GetPlayers()) do
		local char = workspace:FindFirstChild(plr.Name)
		if char then
			local pet = char:FindFirstChildOfClass("Model")
			if (pet and pet:FindFirstChild("Tag")) then
				for _,part in pairs(pet:GetDescendants()) do
					if part:IsA("BasePart") or part:IsA("Model") or part:IsA("MeshPart") or part:IsA("UnionOperation") then
						table.insert(ignoredParts, part)
					end
				end
			end
		end
	end

	--Hyperbomb Lasers
	--[[for _,part in pairs(workspace.CurrentMap:GetChildren()) do
		if part:IsA("Part") and part.Name == "Laser" then
			table.insert(ignoredParts, part)
		end
	end]]

	--for _,explosion in pairs(CS:GetTagged("Explosions")) do
		--table.insert(ignoredParts, explosion)
	--end
end
CreateIgnoredPartsList()

local function getMouseHit(ignoreList)
	local mouseLocation = UIS:GetMouseLocation()
	local viewportPointRay = currentCamera:ViewportPointToRay(mouseLocation.X, mouseLocation.Y)
	local extendedRay = Ray.new(viewportPointRay.Origin, viewportPointRay.Direction * 1000)

	return UIS:FindPartOnRayWithIgnoreList(extendedRay, ignoreList)
end

script.Parent:WaitForChild("FetchMousePos").OnClientInvoke = function()
	--return Mouse.Hit.p
	--local ignoredList = FetchIgnoreList:InvokeServer()
	--local _, position = getMouseHit(ignoredParts)
	local _, position = getMouseHit(ignoredParts)
	print(position)
	return position
end
1 Like

bro just use regular Raycast
besides FindPartOnRayWithIgnoreList is deprecated

FindPartOnRayWithIgnoreList() is a method of Workspace, not UserInputService.