I'm making a gun, and want to make it so that when you click the mouse ignores Non Collide parts. I investigated to see how to Ignore parts and found one:
local Mouse = game.Players.LocalPlayer:GetMouse()
local Descendants = game.Workspace:GetChildren()
local IgnoreList = {}
for i, v in pairs(Descendants) do
if v:IsA("Part") and v.CanCollide == false then
table.insert(IgnoreList, v)
mouse.TargetFilter = v
end
end
for i, v in ipairs(IgnoreList) do
mouse.TargetFilter = v
end
This script does look correct, but I don't know where to place it.. Here's the mouse detect script:
local Mouse = game.Players.LocalPlayer:GetMouse()
local Descendants = game.Workspace:GetChildren()
local IgnoreList = {}
script.Parent.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
local Gun = script.Parent:FindFirstChild("Gun")
script.Parent.Event:FireServer(Gun.Start.Position, mouse.Hit.p)
end)
end)
I don't know if I should change My script or just add this code to it, If I do have to add it, where do i put it?
