Okay so on Line 2 if I remove the randomness from that and make it the same number everytime the if statement below works fine. (If statment is on line 7)
But when I add a random number generator like i have above. The if statement never fires.
if HitPart.Parent.Humanoid.Health > 0 then HitPart.Parent.Humanoid:TakeDamage(Random.new():NextNumber(15, 20)) HitPart.Parent.HealthGui.MainFrame.Bar:TweenSize(UDim2.new(HitPart.Parent.Humanoid.Health/HitPart.Parent.Humanoid.MaxHealth, 0, 1, 0), "Out", "Quad", .25, true) if HitPart.Parent.Humanoid.Health == 0 then if HitPart.Parent:FindFirstChild("Dead") == nil then local Debounce = Instance.new("IntValue") Debounce.Name = "Dead" Debounce.Parent = HitPart.Parent ReplicatedStorage.RoundStats.CurrentEnemyCount.Value = ReplicatedStorage.RoundStats.CurrentEnemyCount.Value - 1 ReplicatedStorage.RoundStats.EnemiesLeft.Value = ReplicatedStorage.RoundStats.EnemiesLeft.Value - 1 DebrisService:AddItem(HitPart.Parent, GameSettings.EnemySettings.EnemyDespawnTime) end end end
Can anyone help me to understand this? The humanoid dies so its health is at 0 so It confuses me as to why it isnt firing.
I HAVE SINCE SOLVED THIS I just changed .Health == 0 to .Health <= 0