Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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
0
you want it to wait before giving them the exp or what? RobloxianDestory 262 — 7y

2 answers

Log in to vote
0
Answered by
saenae 318 Moderation Voter
7 years ago

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.

Ad
Log in to vote
0
Answered by
Prioxis 673 Moderation Voter
7 years ago
Edited 7 years ago
for i,v in pairs (game.Players:GetPlayers()) do
v.PlayerGui.ScreenGui.ExperiencePointsIntValue.Value = v.PlayerGui.ScreenGui.ExperiencePointsIntValue.Value + 1
wait(0.03125)
end

Answer this question