Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Gun script doesn't detect humanoid killed?

Asked by 5 years ago
01local Damage = 25
02local HeadshotDamage = 50
03local Debounce = false
04 
05script.Parent.FireEv.OnServerEvent:Connect(function(Player, Shooter, MousePos)
06    if script.Parent.Ammo.Value == 0 then return end
07    script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
08    script.Parent.FirePart.Fire:Play()
09    local Bullet = Instance.new("Part", workspace)
10    Bullet.CFrame = script.Parent.FirePart.CFrame
11    Bullet.Size = Vector3.new(0.15, 0.15, 0.15)
12    Bullet.BrickColor = BrickColor.new("Bright yellow")
13    Bullet.TopSurface = "Smooth"
14    Bullet.BottomSurface = "Smooth"
15    Bullet.Material = "Neon"
View all 53 lines...

There are no errors, but when it reaches the point where it checks if a humanoid died, it doesn't print anything after I kill another player.

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

I think it's because the Hum.Died event will only run if it was a headshot because it's under the if statement that checks if it was a headshot. To fix it it should b e something like that:

01local Damage = 25
02local HeadshotDamage = 50
03local Debounce = false
04 
05script.Parent.FireEv.OnServerEvent:Connect(function(Player, Shooter, MousePos)
06    if script.Parent.Ammo.Value == 0 then return end
07    script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
08    script.Parent.FirePart.Fire:Play()
09    local Bullet = Instance.new("Part", workspace)
10    Bullet.CFrame = script.Parent.FirePart.CFrame
11    Bullet.Size = Vector3.new(0.15, 0.15, 0.15)
12    Bullet.BrickColor = BrickColor.new("Bright yellow")
13    Bullet.TopSurface = "Smooth"
14    Bullet.BottomSurface = "Smooth"
15    Bullet.Material = "Neon"
View all 54 lines...

Now, I'm not sure about it, but it might be the problem. If it still doesn't work, please make a comment in my answer.

0
I added to that, but it didn't seem to fix the issue itchymoonfire 179 — 5y
Ad

Answer this question