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)
local deagle = script.Parent
deagle.Shoot.OnServerEvent:Connect(function(player,mousePos)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(deagle.Handle.Position,(mousePos - deagle.Handle.Position)*2147000,raycastParams)
deagle.Handle.GunShot:Play()
if raycastResult then
local hitPart = raycastResult.Instance
local model = hitPart:FindFirstAncestorOfClass("Model")
if model then
if model:FindFirstChild("Humanoid").Health >= 0 then
if model.Humanoid.Health <= 28 then
player.leaderstats.Kills.Value = player.leaderstats.Kills.Value + 1
end
model.Humanoid.Health -= 36
elseif model:FindFirstChild("Humanoid").Health <= 0 then
--nothing
end
end
end
end)
