I made a status effect module, but I am having problems with it.
For some reason, the fire effect is doing an unexpected amount of damage. It is supposed to deal only 2 damage.
The video here shows the player’s HP each tick.
Here is the code:
["Burning"] = function(Duration, Char:Model)
--|| Fire Configs ||--
local DMG = 2
local Rate = 1
local Fire = Effects.Fire
local Description = "Deals damage over time."
local ImageID = 2005880937
--//
local Humanoid = Char:FindFirstChildOfClass("Humanoid")
local PrimaryPart = Char.PrimaryPart
local effectsFolder = EffectsFolder(Char)
if effectsFolder:FindFirstChild("Burning") then
local BurningTag = effectsFolder:FindFirstChild("Burning")
AddDuration(Duration, BurningTag)
else
local NewTag = newTag("Burning", Duration, effectsFolder)
local FireClone = Fire:Clone()
FireClone.Parent = Char.PrimaryPart
local NewUI
if game:GetService("Players"):GetPlayerFromCharacter(Char) then
local plr = game:GetService("Players"):GetPlayerFromCharacter(Char)
NewUI = NewStatusEffectUI(ImageID, "Burning", Description)
NewUI.Parent = plr.PlayerGui.StatusEffects.MainHolder
end
while NewTag.Value > 0 do
if Humanoid.Health <= 0 then
DestroyTagData(NewTag, FireClone, NewUI)
break
end
if NewUI then
UpdateEffectUI(NewUI, NewTag.Value)
end
Humanoid:TakeDamage(DMG)
print(Humanoid.Health)
NewTag.Value -= Rate
task.wait(Rate)
end
DestroyTagData(NewTag, FireClone, NewUI)
end
end,
Help would be appreciated.