For some reason, the “Shot” sound effects (2 different sounds) don’t play when an npc fires a gun, but the “Reload” sound effect does even though both are under a gun.
Reload code snippet:
function reload()
if weaponAimed == true then
resetHead()
weaponAimed = false
end
reloadSound:Play()
reloading = true
Shoot code snippet
function shoot(target)
if weaponCool == true and reloading == false and canShoot == true then
weaponCool = false
canShoot = false
local shot = 1
for i = 1, shot do
task.wait(0.1)
mag = 1
mag = mag - 1 -- ignore this 😭
fireSound:Play()
fireSound2:Play()
Also, I’m modifying a free model script so that’s kinda why its like that.
It’s quite a mess. (Note I did not write this lol
function shoot(target)
if weaponCool == true and reloading == false and canShoot == true then
weaponCool = false
canShoot = false
local shot = 1
for i = 1, shot do
task.wait(0.1)
mag = 1
mag = mag - 1
local flash = Instance.new("PointLight",barrel)
flash.Brightness = 0
game:GetService("Debris"):AddItem(flash,0.1)
local bullet = Instance.new("Part")
bullet.Size = Vector3.new(0.1,0.1,0.3)
bullet.BrickColor = BrickColor.new("Gold")
bullet.Material = Enum.Material.Neon
bullet.CFrame = barrel.CFrame
bullet.CanCollide = false
fireSound:Play()
fireSound2:Play()
print("soundsplayed")
bullet.Touched:Connect(function(obj)
if not obj:IsDescendantOf(script.Parent) then
local human = obj.Parent:FindFirstChild("Humanoid")
if human then
if human.Torso then return end
if obj.Name == "Head" then
human:TakeDamage(50)
else
human:TakeDamage(math.random(20,25))
if human.Health <= 0 then
kill = true
end
end
end
bullet:Destroy()
end
end)
bullet.Parent = workspace
local spread = Vector3.new(math.random(-shot,shot)/100,math.random(-shot,shot)/100,math.random(-shot,shot)/100)
local bv = Instance.new("BodyVelocity",bullet)
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = (aimer.CFrame.LookVector + spread) * 300
local s = Instance.new("Sound",bullet)
s.Volume = 0.7
s.PlaybackSpeed = 7
s.Looped = true
s.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
s:Play()
local a1 = Instance.new("Attachment",bullet)
a1.Position = Vector3.new(0,0.05,0)
local a2 = Instance.new("Attachment",bullet)
a2.Position = Vector3.new(0,-0.05,0)
local t = Instance.new("Trail",bullet)
t.Attachment0 = a1
t.Attachment1 = a2
t.Color = ColorSequence.new(bullet.Color)
t.WidthScale = NumberSequence.new(0.1,0.01)
t.Lifetime = 0.3
aimerWeld.Part1 = nil
aimer.CFrame = aimer.CFrame * CFrame.Angles(math.rad(math.random(1,4)/4),0,0)
aimerWeld.Part1 = aimer
game:GetService("Debris"):AddItem(bullet, 5)
end
if mag <= 0 then
reload()
end
if kill == true then
task.wait(3)
weaponCool = true
canShoot = true
return
end
weaponCool = true
task.wait(4)
canShoot = true
end
end
Yes, it prints and the model “SoldierNPC” is under workspace. I don’t think it has to do with that since the reload is located the same place and yet it still plays.
P.S, the properties of the fire and reload sound effect are the same except for length, volume, and playbackspeed.
Apparently, the thing was the “RollOffMinDistance” was at 0 and supposedly was supposed to be at 10. That made it work, but since you at least tried helping I’ll give you the solution. Thanks for your time!