function functions.AddBurn(char,b)
if collectionService:HasTag(char,b.Name.."Burn") then return end
collectionService:AddTag(char,b.Name.."Burn")
task.delay(b.Dura,function()
if collectionService:HasTag(char,b.Name.."Burn") then
collectionService:RemoveTag(char,b.Name.."Burn")
end
end)
repeat task.wait(b.Tick)
manualdamage(char,b.Dmg,1)
until not collectionService:HasTag(char,b.Name.."Burn")
end
this is a burn function you should pretty much understand that part
function functions.RemoveBurn(char,b)
if collectionService:HasTag(char,b.Name.."Burn") then
collectionService:RemoveTag(char,b.Name.."Burn")
end
end
i need this function so i can manually remove the burn at any time
the problem is however if i manually remove the burn then add the same burn again its gonna be removed earlier due to the task.delay() function removing the tag after the duration if it exists, example i add a 15 second burn then remove it after 5 seconds and instantly add the same one back its gonna be removed in 10 seconds because the task.delay() part waited 5 already i need the best workaround let me know if it doesnt make sense thx
You should add a variable timer outside the repeat until that increases over time.
function functions.AddBurn(char,b)
if collectionService:HasTag(char,b.Name.."Burn") then return end
collectionService:AddTag(char,b.Name.."Burn")
local t = 0
repeat t += task.wait(b.Tick)
manualdamage(char,b.Dmg,1)
until not collectionService:HasTag(char,b.Name.."Burn") or t > b.Dura
if collectionService:HasTag(char,b.Name.."Burn") then
collectionService:RemoveTag(char,b.Name.."Burn")
end
end
Oh, alright. Mark your post as the solution since you solved it already. I didn’t know task.cancel actually exists.
Anyways I will just talk about threads. Threads are lines of commands/code that runs and yields the whole thread if it “waits”. If a different thread yields, the current one won’t. But since a thread is a like “script”, making many of those may lag. task.spawn and task.delay creates a thread every time you call them. So calling them many times may lag.