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)