Hi everyone first time posting here. Anyways you can correct me on how I posted this after but I got an annoying problem that ive been tryna fix for sometime now by going through different approaches but still getting problems at the end of each approach.
Am tryna make a burning damage system for when the enemies (NPCs) touch the hitboxes. What I’ve done is put the particle emitter in the NPCs bodies before hand (this was a changed from just replicating it from replicated storage), make a local function which checks if the enemy is on the Whitelist before being hit, loop for HumanoidRootPart then damage the NPC upon the loop finding HRP, have another loop which will check for the Particles inside the NPCs and emit them and then finally add the hit NPC in Whitelist table
Now running this once works perfectly fine, but running it multiple times (by calling it multiple times after clearing the Whitelist table) makes the script do way more damage than its supposed to
The problem is that when i remove the task.wait(1) in the .Touched event function and just make it damage the player once, it works perfectly. But if i run it multiple times, it doesnt
Maybe it’s because there are multiple threads checking to damage the player, and these threads are all trying to damage the player after each other in 1 second bursts.
Try adding a damage cooldown, or use CollectionService to tag the player whether they’re on fire or not.
local collectionService = game:GetService("CollectionService")
local part = nil -- This can be any instance
collectionService:AddTag(part, "Burning") -- Adds a tag to part
collectionService:HasTag(part, "Burning") -- Checks if a tag exists on part
collectionService:RemoveTag(part, "Burning") -- Removes a tag from part