Script not cloning fire to all players (i figured out the bug but idk how to fix it for some reason)

The script is not actually cloning the fire particle to all players, I know why, It’s because this script only clones the fire particle to player character head 1 times If you know what i mean, Should i try fix it with a loop until fires are cloned to all players head or something else?

for _,player in ipairs(game.Players:GetPlayers()) do
local character = player.Character
local head = character.Head
local fire = script.Fire:Clone()
	fire.Parent = head
	wait(5)
	character.Humanoid.Health = 0
	script:Destroy()
end
1 Like
for _,player in ipairs(game.Players:GetPlayers()) do
	spawn(function()
		local character = player.Character
		local head = character.Head
		local fire = script.Fire:Clone()
		fire.Parent = head
		task.wait(5) -- new wait, more efficient and accurate
		character.Humanoid.Health = 0
	end)
end
script:Destroy()
1 Like

When i tried it, It didn’t work, like it didn’t do anything. Have you tried it? I can give you something that comes with that script so you can test it out with your changes

It is highly recommended that you do not use spawn() or delay() due to it being deprecated, you can use coroutine instead for efficient functioning, you can just replace your spawn with coroutine.wrap()
(Reminder that the () near the end) is necessary to call the function after definition)

coroutine.wrap(function()
   -- code
end)()
1 Like

There’s also the new task library, which has task.spawn(), task.defer(), and task.delay(), which are improved versions of the older functions.

1 Like

Alright, Also sorry for accidently making other post a solution, I will try that and will_rocks1 and star method