Script helping Ignoring parts

Local Script:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
	if mouse.Target == nil then
	else
		while wait() do
			game.ReplicatedStorage.Fire:FireServer(player,mouse.Hit)
		end
	end
end)

Script:

   game.ReplicatedStorage.Fire.OnServerEvent:Connect(function(x,player,mouse)
    	local Part = Instance.new("Part",workspace)
    	Part.Anchored = true 
    	Part.CanCollide = false
    	warn(mouse)
    	Part.CFrame = mouse
    	wait(.2)
    	Part:Destroy()
    end)

Problem: this script working like this

I want this:

1 Like

You’re gonna want to put all the parts in a specific folder and then use Mouse.TargetFilter to blacklist all the descendants of that folder from blocking the mouse’s hit position.

https://developer.roblox.com/en-us/api-reference/property/Mouse/TargetFilter

Since it’s just 1 or 2 extra lines I’ve decided to just add them in for you

Localscript:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.TargetFilter = workspace.MouseIgnores --Needs a folder in workspace called MouseIgnores
mouse.Button1Down:Connect(function()
	if mouse.Target == nil then
	else
		while wait() do
			game.ReplicatedStorage.Fire:FireServer(player,mouse.Hit)
		end
	end
end)
game.ReplicatedStorage.Fire.OnServerEvent:Connect(function(x,player,mouse)
	local Part = Instance.new("Part")
	Part.Anchored = true 
	Part.CanCollide = false
	warn(mouse)
	Part.CFrame = mouse
	Part.Parent = workspace.MouseIgnores --Needs a folder in workspace called MouseIgnores
	wait(.2)
	Part:Destroy()
end)

Create model from parts
and use this

local mouse = game.Players.LocalPlayer:GetMouse()
local Model = ModelHere
mouse.TargetFilter = Model

Hello