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

How do you make it so it gives the experience points to all the players at the same time?

How do you make it so it gives the experience points to all the players at the same time while waiting (0.03125)? This script gives the experience to one person first, waits, then gives it to the next person. How can you make this happen without placing a script in every player. The script must be in Workspace. Thanks!

for _, player in pairs(game.Players:GetPlayers()) do
	for i = 1, player.leaderstats.Score.Value do
		player.PlayerGui.ScreenGui.ExperiencePointsIntValue.Value =	player.PlayerGui.ScreenGui.ExperiencePointsIntValue.Value + 1
		wait(0.03125)
	end
end

1 comment

0

you want it to wait before giving them the exp or what?

2 answers

✓ Accepted answer

You can just wrap the inner block with a coroutine.

for _, player in pairs(game.Players:GetPlayers()) do
	coroutine.wrap(function()
		for i = 1, player.leaderstats.Score.Value do
			player.PlayerGui.ScreenGui.ExperiencePointsIntValue.Value = player.PlayerGui.ScreenGui.ExperiencePointsIntValue.Value + 1
			wait(0.03125)
		end
	end)()
end

Now everything should happen (virtually) simultaneously on every player.

for i,v in pairs (game.Players:GetPlayers()) do
v.PlayerGui.ScreenGui.ExperiencePointsIntValue.Value = v.PlayerGui.ScreenGui.ExperiencePointsIntValue.Value + 1
wait(0.03125)
end

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