How would i use a raycast params for what i wanna do?

Basically, im making a gun system like Isle, and rn what i need is that it shoots a raycast to see if theres any parts in the way the players is shooting, so if theres any parts blocking it wont shoot

But how i would make that?
Idk if i explained well

The script

local tool = script.Parent
local remote = tool:WaitForChild("OnShoot")
local shoot_part = tool:WaitForChild("FirePart")
local Config = tool.Config
local Damage = Config.Damage.Value
local SFX = tool:WaitForChild("Handle")

local particles = {
	particle1 = shoot_part:WaitForChild("10"),
	particle2 = shoot_part:WaitForChild("20")
}

local damage = Config.Damage.Value
local Bullets = Config.Bullets.Value
local Cooldown = Config.Cooldown.Value
local finish = Config.Finish.Value

local Shooting = false

remote.OnServerEvent:Connect(function(player, target)
	if not Shooting and Config.Ammo.Value > 0 and (player.Character.HumanoidRootPart.Position-target.Position).magnitude <= 100 then
		local params = RaycastParams.new()
		params.FilterType = Enum.RaycastFilterType.--???
		params.FilterDescendantsInstances = --???
		
		Shooting = true
		tool.Aim:FireClient(player)
		wait(Cooldown)
		local raycast = workspace:Raycast(shoot_part.Position, (target.Position-shoot_part.Position).unit*1000, params)
		if raycast then
			particles.particle1.Enabled = true particles.particle2.Enabled = true
			tool.Shoot:FireClient(player)
			target.Parent.ZombieNoid:TakeDamage(Damage)
			particles.particle1.Enabled = false particles.particle2.Enabled = false
		else
			tool.Cancel:FireClient(player)
			Shooting = false
		end
	end
end)

Here you don’t need to filter any instances as you are checking if there is something touching the gun muzzle and avoid shooting the gun

but then how would i made it to check if there isnt any wall behind the enemy, bc if i dont filter it it would detect any part as a wall right?

Sorry for replying late

1 Like

You can check if the impact object parent has an humanoid as child, if yes, then it’s an enemy.

ohhh raycastresult.Instance right?

1 Like

Yes, that it’s the impact object

1 Like