How to stop getting added kills when shooting dead enemy?
Asked by
4 years ago Edited 4 years ago
I made a script for a gun I made but when the enemy is dead, I can still shoot the enemy and still get added to my kills leaderstats. What is the problem? Script below (Is a Server Script)
01 | local deagle = script.Parent |
03 | deagle.Shoot.OnServerEvent:Connect( function (player,mousePos) |
04 | local raycastParams = RaycastParams.new() |
05 | raycastParams.FilterDescendantsInstances = { player.Character } |
06 | raycastParams.FilterType = Enum.RaycastFilterType.Blacklist |
09 | local raycastResult = workspace:Raycast(deagle.Handle.Position,(mousePos - deagle.Handle.Position)* 2147000 ,raycastParams) |
11 | deagle.Handle.GunShot:Play() |
13 | local hitPart = raycastResult.Instance |
14 | local model = hitPart:FindFirstAncestorOfClass( "Model" ) |
17 | if model:FindFirstChild( "Humanoid" ).Health > = 0 then |
18 | if model.Humanoid.Health < = 28 then |
19 | player.leaderstats.Kills.Value = player.leaderstats.Kills.Value + 1 |
21 | model.Humanoid.Health - = 36 |
22 | elseif model:FindFirstChild( "Humanoid" ).Health < = 0 then |