Hello, my Problem is, my guns somehow not shooting Through Accessories or even some other stuff…
As you can see its stuck on AIR
Here is my Local Script:
For Mouse.Hit.Position
function fire()
if equipped then
WEAPON_FIRE_REMOTE:FireServer(tool)
if fanning.Value == false then
fireAnim:Play()
elseif fanning.Value == true then
fanFireAnim:Play()
end
ammo -= 1
for i = 1, GunStats.Bullets do
local spreadX = rand((-GunStats.MaxBulletSpread * 1000) / 1000, (GunStats.MaxBulletSpread * 1000) / 1000)
local spreadY = rand((-GunStats.MaxBulletSpread * 1000) / 1000, (GunStats.MaxBulletSpread * 1000) / 1000)
mouse.TargetFilter = char
if mouse.Hit then
mouse.Icon = "rbxassetid://6976622370"
tool.HitSound:Play()
tool.HitSoundHead:Play()
WEAPON_DAMAGE_REMOTE:FireServer(tool, mouse.Hit.Position, muzzle)
delay(0.1, mouseIconReturn)
end
local verti = rand(GunStats.VerticalRecoil[1], GunStats.VerticalRecoil[2]) / 100
local horiA = rand(GunStats.HorizontalRecoil[1], GunStats.HorizontalRecoil[2]) / 100
local horiB = rand(GunStats.HorizontalRecoil[1], GunStats.HorizontalRecoil[2]) / 100
recoilCF = recoilCF:Lerp(cfnew() * cfang(rad(verti), rad(horiA), rad(horiB)), 0.4)
end
end
end
Here is my ServerScript:
WEAPON_DAMAGE_REMOTE.OnServerEvent:Connect(function(player, tool, position, origin)
if tool.Parent == player.Character then
local GunStats = gunModule[tool.Name]
local Damage
local c = player.Character or player.CharacterAdded:Wait()
local lHuman = c:WaitForChild("Humanoid")
local direction = (position - origin.Position).Unit*100
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
local excludedInstances = {}
for _, player in ipairs(game.Players:GetPlayers()) do
if player.Character then
for _, accessory in ipairs(player.Character:GetChildren()) do
if accessory:IsA("Accessory") then
table.insert(excludedInstances, accessory) -- Only exclude the accessory parts
end
end
for _, tool in ipairs(player.Character:GetChildren()) do
if tool:IsA("Tool") then
table.insert(excludedInstances, tool) -- Only exclude the accessory parts
end
end
end
end
local result = Workspace:Raycast(origin.Position, direction, params)
local intersection = result and result.Position or origin.Position + direction
local distance = (origin.Position - intersection).Magnitude
local bullet_clone = ReplicatedStorage.Assets.Bullet:Clone()
bullet_clone.Size = Vector3.new(0.1, 0.1, distance)
bullet_clone.CFrame = CFrame.new(origin.Position, intersection)*CFrame.new(0, 0, -distance/2)
bullet_clone.Parent = Workspace.BulletsIgnore
bullet_clone.Transparency = 0.5
Debris:AddItem(bullet_clone, 10)
local function AddBullet()
local bullet = ReplicatedStorage.Assets.Bullet:Clone()
local BulletWeld = Instance.new("WeldConstraint")
BulletWeld.Part0 = bullet
BulletWeld.Part1 = result.Instance
BulletWeld.Parent = bullet
bullet.Position = position
bullet.Anchored = false
bullet.Decal.Color3 = result.Instance.Color
bullet.ParticleEmitter.Color = ColorSequence.new(result.Instance.Color, result.Instance.Color)
bullet.Parent = workspace.BulletsIgnore
bullet.ParticleEmitter:Emit(math.random(1, 14))
bullet.Sound.PlaybackSpeed = math.random(80, 120)/100
bullet.Sound:Play()
Debris:AddItem(bullet, 20)
end
params.FilterDescendantsInstances = {}
params.FilterDescendantsInstances = {
c:GetChildren(),
Workspace.BulletsIgnore:GetChildren(),
tool:GetChildren(),
unpack(excludedInstances)
}
if result then
local part = result.Instance
local Health = part:FindFirstChild("Health") or part.Parent:FindFirstChild("Health") or part.Parent.Parent:FindFirstChild("Health")
if Health then
local function AddBlood()
local blood = ReplicatedStorage.Assets.Blood:Clone()
local BloodWeld = Instance.new("WeldConstraint")
BloodWeld.Part0 = blood
BloodWeld.Part1 = part
BloodWeld.Parent = blood
blood.Position = position
blood.Anchored = false
blood.Parent = workspace.BulletsIgnore
blood.ParticleEmitter:Emit(math.random(1, 3))
blood.Sound.PlaybackSpeed = math.random(220, 240)/100
blood.Sound:Play()
Debris:AddItem(blood, 20)
end
local partName
local partParent
if part:IsA("BasePart") then
partName = part.Name
partParent = part.Parent
end
-- Check if the hit part is the head, torso, legs, or arms
if partName == "Head" then
Damage = GunStats.HeadDamage
elseif partName == "Torso" or partName == "UpperTorso" or partName == "LowerTorso" or
part.Name == "HumanoidRootPart" or
part.Name == "Hitbox" or part.Name == "HitBox" then
Damage = GunStats.TorsoDamage
elseif partName == "LeftLeg" or partName == "RightLeg" or
partName == "LeftFoot" or partName == "RightFoot" or
partName == "LeftHand" or partName == "RightHand" or
partName == "LeftLowerArm" or partName == "RightLowerArm" or
partName == "LeftLowerLeg" or partName == "RightLowerLeg" or
partName == "LeftUpperArm" or partName == "RightUpperArm" or
partName == "LeftUpperLeg" or partName == "RightUpperLeg" then
Damage = GunStats.LimbDamage
end
if partName ~= "Hitbox" then
print(partName)
AddBlood()
Health.Value -= Damage
elseif partName == "Hitbox" or partName == "HitBox" then
--- DEFINE SPECIAL STUFF HERE
if partParent.Name == "TNT" then
Health.Value -= Damage
end
end
end
end
AddBullet()
end
end)
Even though I added them to Ignore List, or even Tried RayCast on Local Script to Ignore Accessories etc. it always breaks somehow or still give same issue