Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make this script work for everyone at the same time?

I made this script:

script.Parent.Explosion.Changed:Connect(function(value)
	if value == true then
		for i, player in pairs(game.Players:GetPlayers()) do
			local gui = script.Parent.Meltdown1
			gui:Clone().Parent = player.PlayerGui
			wait(15)
			player.PlayerGui.Meltdown1:Destroy()
			script.Parent.Explosion.Value = false
		end
	end
end)

The problem is its working for first player, then waiting 15 seconds and only then start working for second player. I need it to work for every player at the same time. Can someone help me?

4 comments

0

You are using a loop. I think you may have to use a coroutine (don't get it mixed up with quarantine)

0

lol

0

And how to do it?

0

Check my answer.

1 answer

✓ Accepted answer

This might work, but I haven't tested it:

script.Parent.Explosion.Changed:Connect(function(value)
    if value == true then
        for i, player in pairs(game.Players:GetPlayers()) do
            local gui = script.Parent.Meltdown1
            gui:Clone().Parent = player.PlayerGui
         end
         wait(15)
         for i,v in pairs(game.Players:GetPlayers()) do
                player.PlayerGui.Meltdown1:Destroy()
                script.Parent.Explosion.Value = false
         end
    end
end)

Hope this helps! :D

1 comment

0

Took me long to test, but it works.

This discussion is preserved as it was. New answers, comments, and votes are closed.