(SOLVED) Need help with the burning dmg module(runservice.Stepped issue)

hi guys. i got this while using my burning system, when the target got hit the damage was stacked, instead of dealing 1 time per hit it deals 6 times
Here a part of the system:

function module.BurnHit(Info)
	local self = setmetatable({}, module)
	local OnHit = Instance.new("BindableEvent")
	self.OnHit = OnHit.Event
	self.Hit = OnHit
	local Hitbox = Instance.new("Part", workspace)
	Hitbox.Size = Info.Size
	Hitbox.CFrame = Info.CFrame
	Hitbox.Anchored = true
	Hitbox.CanCollide = false
	Hitbox.CanQuery = false
	Hitbox.Transparency = 1
	game:GetService("Debris"):AddItem(Hitbox, 1)
	local cf = Hitbox.CFrame
	local size = Hitbox.Size
	local overlap = OverlapParams.new()
	overlap.FilterDescendantsInstances = {workspace.Db, game:GetService("CollectionService"):GetTagged("WindShake"), game:GetService("CollectionService"):GetTagged("Swim"), Info.Char:GetDescendants(), Info.Avoid}

	local hitchar = {}
	local idk = workspace:GetPartBoundsInBox(cf, size, overlap)
	local no = 1

	for i, p in pairs(idk) do
		local cd = false
		local dmg = 0
		local step
		if p.Parent:FindFirstChild("HumanoidRootPart") and p.Parent.Name ~= Info.Char.Name and p.Parent:FindFirstChild("Torso") and p.Parent:FindFirstChildOfClass("Humanoid") then
			if not table.find(hitchar, p.Parent) then
				table.insert(hitchar, p.Parent)
				--DealUnphysicaldDmg(Info.Dmg, p.Parent, Info.Char, Info.CritChanceBonus, Info.CritDmgBonus, Info.Player)
			else
				task.spawn(function()
					if step then
						step:Disconnect()
					end
					step = rS.Stepped:Connect(function()
						if not cd then
							cd = true
							if dmg < Info.TotalDmgDeal/no then
								print("Burn")
								dmg += Info.Dmg/no
								DealNonCritDmg(Info.Dmg/no, p.Parent, Info.Char, Info.CritChanceBonus, Info.CritDmgBonus, Info.Player)
								OnHit:Fire(p.Parent)
							elseif dmg >= Info.TotalDmgDeal/no then 
								step:Disconnect()
							end
							task.delay(Info.DelayTime, function()
								cd = false
							end)
						end
					end)
				end)
			end
		end
	end

	overlap:AddToFilter(hitchar)
end

Client Side:

			local BasicInfo = {}
			BasicInfo.Dmg = 5
			BasicInfo.Physical = false
			BasicInfo.Char = c
			BasicInfo.CFrame = hitVFX.CFrame
			BasicInfo.Pos = hitVFX.Position
			BasicInfo.PARENT = hitVFX
			BasicInfo.CritChanceBonus = 10
			BasicInfo.CritDmgBonus = 25
			BasicInfo.Range = 0
			BasicInfo.Size = folder2.StrikeArea.Size
			BasicInfo.Avoid = nil
			BasicInfo.DelayTime = .4--the time distance between each attack
			BasicInfo.TotalDmgDeal = 50
			BasicInfo.Player = p
			folder2.FindPart:FireServer("Shock", BasicInfo)

Server Side:

folder.FindPart.OnServerEvent:Connect(function(p, Style, Info)
	if Style == "Shock" then
		findPartModule.BurnHit(Info)
	end
end)

here’s the dummies im using

the damage that they got:
Ảnh chụp màn hình 2024-11-16 131742
also the damage for single dummy:
image

im using the damage indicator to detecting the damages
as you can see, the module deals more than 1 time per BasicInfo.DelayTime--the time distance between each attack,

Sorry for poorly explaining, English was not my origin language

is there any way to fix this?

Try this,

function module.BurnHit(Info)
	local self = setmetatable({}, module)
	local OnHit = Instance.new("BindableEvent")
	self.OnHit = OnHit.Event
	self.Hit = OnHit
	local Hitbox = Instance.new("Part", workspace)
	Hitbox.Size = Info.Size
	Hitbox.CFrame = Info.CFrame
	Hitbox.Anchored = true
	Hitbox.CanCollide = false
	Hitbox.CanQuery = false
	Hitbox.Transparency = 1
	game:GetService("Debris"):AddItem(Hitbox, 1)
	local cf = Hitbox.CFrame
	local size = Hitbox.Size
	local overlap = OverlapParams.new()
	overlap.FilterDescendantsInstances = {workspace.Db, game:GetService("CollectionService"):GetTagged("WindShake"), game:GetService("CollectionService"):GetTagged("Swim"), Info.Char:GetDescendants(), Info.Avoid}

	local hitchar = {}
	local idk = workspace:GetPartBoundsInBox(cf, size, overlap)
	local no = 1

	for i, p in pairs(idk) do
		local cd = false
		local dmg = 0
		local step
		if p.Parent:FindFirstChild("HumanoidRootPart") and p.Parent.Name ~= Info.Char.Name and p.Parent:FindFirstChild("Torso") and p.Parent:FindFirstChildOfClass("Humanoid") then
			if not table.find(hitchar, p.Parent) then
				table.insert(hitchar, p.Parent)
				--DealUnphysicaldDmg(Info.Dmg, p.Parent, Info.Char, Info.CritChanceBonus, Info.CritDmgBonus, Info.Player)
			
				task.spawn(function()
					if step then
						step:Disconnect()
					end
					step = rS.Stepped:Connect(function()
						if not cd then
							cd = true
							if dmg < Info.TotalDmgDeal/no then
								print("Burn")
								dmg += Info.Dmg/no
								DealNonCritDmg(Info.Dmg/no, p.Parent, Info.Char, Info.CritChanceBonus, Info.CritDmgBonus, Info.Player)
								OnHit:Fire(p.Parent)
							elseif dmg >= Info.TotalDmgDeal/no then 
								step:Disconnect()
							end
							task.delay(Info.DelayTime, function()
								cd = false
							end)
						end
					end)
				end)
			end
		end
	end

	overlap:AddToFilter(hitchar)
end

What i did is basically, removed the else statement on the “if not table.find()” section.

I’ll try to break it down for you (only read if it worked lol)

You put the Hit Character onto a table, which is correct… BUT you need to also place the Damage or Burning Händler whatever you call it onto that same part as the one the table.insert(HitChar,p.Parent) in, which you didn’t do.

In short, you only made it check if the hit character is in a table and if it didn’t, you put it into a table… and that’s it. You placed the rest of the burning handler script thingy on a else statement.

1 Like

tysm for replying but i found another solution for that, i just changed the requirement from
if p.Parent:FindFirstChild("HumanoidRootPart") and p.Parent.Name ~= Info.Char.Name and p.Parent:FindFirstChild("Torso") and p.Parent:FindFirstChildOfClass("Humanoid") then
to
if p.Parent:FindFirstChild("HumanoidRootPart") and p.Parent.Name ~= Info.Char.Name and p.Parent:FindFirstChild("Torso") and p.Parent:FindFirstChildOfClass("Humanoid") and not table.find(hitchar, p.Parent) then
also replaced runservice to function looping like this:

				local function loop()
					if p.Parent.Humanoid.Health > 0 then
						--DealNonCritDmg(Info.Dmg/no, p.Parent, Info.Char, Info.CritChanceBonus, Info.CritDmgBonus, Info.Player)
						DealUnphysicaldDmg(Info.Dmg/no, p.Parent, Info.Char, Info.CritChanceBonus, Info.CritDmgBonus, Info.Player)
						dmgDealt+=Info.Dmg/no

						if dmgDealt < Info.TotalDmgDeal/no then
							task.delay(Info.DelayTime, function()
								if cd == false then
									loop()
								end
							end)
						elseif dmgDealt >= Info.TotalDmgDeal and cd == false then
							cd = true
							stopDealing()
						end
					else
						warn(p.Parent.Name.." was ded")
						stopDealing()
					end
				end
				loop()

its work just like what you said

again, thank for your help i really appreciated it!

1 Like