Xaerium
|
  |
| Joined: 25 Apr 2009 |
| Total Posts: 126 |
|
|
| 17 May 2015 05:02 PM |
Hi, I made a module script that makes an announcement for every player in the game, but I have a problem, it is supposed to do it for all players at the same time, but what it does is do it on 1 player and waits for it to be finished and then does it for the other player, not all at the same time, I know my issue is that I do the for loop for every player and then the for loop for the announcement, but what can I do instead?
function Announcement(Title,LoadTime) for _,v in pairs (game.Players:GetPlayers())do if LoadTime ~= nil then v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[]") v.PlayerGui.NotificationGui.Announcement.Visible = true for i = 1,LoadTime do wait(1) i = 1+1 v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[.]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[..]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[...]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[]") end else v.PlayerGui.NotificationGui.Announcement.Text.Text = Title v.PlayerGui.NotificationGui.Announcement.Visible = true wait(5) end v.PlayerGui.NotificationGui.Announcement.Visible = false end end return Announcement
|
|
|
| Report Abuse |
|
|
loweras
|
  |
| Joined: 20 Feb 2015 |
| Total Posts: 39 |
|
|
| 17 May 2015 05:03 PM |
| Im guessing you have it as a startergui? |
|
|
| Report Abuse |
|
|
Xaerium
|
  |
| Joined: 25 Apr 2009 |
| Total Posts: 126 |
|
|
| 17 May 2015 05:22 PM |
| Correct, but if it was a startergui, I would have to reset them every time? |
|
|
| Report Abuse |
|
|
Xaerium
|
  |
| Joined: 25 Apr 2009 |
| Total Posts: 126 |
|
|
| 17 May 2015 05:23 PM |
| Yes, it is a startergui, but if I edit the startergui, wouldnt I have to reset them every time so that they can see it? |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 05:26 PM |
What is this For? Saying updates? Raids? |
|
|
| Report Abuse |
|
|
loweras
|
  |
| Joined: 20 Feb 2015 |
| Total Posts: 39 |
|
|
| 17 May 2015 05:30 PM |
| If it's a startergui when the player joins it will show them the guide, it won't show at the same time unless all the players join at the same time, which would be very, very doubtful. |
|
|
| Report Abuse |
|
|
loweras
|
  |
| Joined: 20 Feb 2015 |
| Total Posts: 39 |
|
|
| 17 May 2015 05:33 PM |
| I'd suggest adding a time to wait at the top of the script, and change the script into a real script, and take it out of the startergui, if that doesn't work I'll try to fix it. |
|
|
| Report Abuse |
|
|
Xaerium
|
  |
| Joined: 25 Apr 2009 |
| Total Posts: 126 |
|
|
| 17 May 2015 05:56 PM |
| This is a module script used in a round-based game, so it gives some announcements during the game. |
|
|
| Report Abuse |
|
|
|
| 17 May 2015 07:01 PM |
| it's because the player has to finish before the loop can move onto the next player. |
|
|
| Report Abuse |
|
|
Xaerium
|
  |
| Joined: 25 Apr 2009 |
| Total Posts: 126 |
|
|
| 18 May 2015 07:26 PM |
| And how can I make it work properly? |
|
|
| Report Abuse |
|
|
Xaerium
|
  |
| Joined: 25 Apr 2009 |
| Total Posts: 126 |
|
| |
|
Xaerium
|
  |
| Joined: 25 Apr 2009 |
| Total Posts: 126 |
|
| |
|
|
| 22 May 2015 08:10 PM |
like the othe rguy said, it has to finish dealing with one player before moving on to the next.
swap them around. for example, instead of this:
for i,v in pairs(game.Players:GetChildren()) do for z=1, 2 do -daaaa wait(1) end end
do this:
for i=1, 2 do for z,c in pairs(game.Players:GetChildren()) do -daaaa end end
for _,v in pairs (game.Players:GetPlayers())do if LoadTime ~= nil then v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[]") v.PlayerGui.NotificationGui.Announcement.Visible = true for i = 1,LoadTime do wait(1) i = 1+1 v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[.]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[..]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[...]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[]") |
|
|
| Report Abuse |
|
|
|
| 22 May 2015 08:10 PM |
| oops, the code at the bottom was just for me to see your post |
|
|
| Report Abuse |
|
|
Xaerium
|
  |
| Joined: 25 Apr 2009 |
| Total Posts: 126 |
|
| |
|
|
| 22 May 2015 09:00 PM |
for i,v in pairs(game.Players:GetChildren()) do --stuff wait(2) -stuff end
in this code, when it loops through all the players, it waits for a total of 2 seconds. the script is yielded for 2 seconds - only after those 2 secodns are passed does it move onto the other player
do this:
for i=1, 2 do for z,c in pairs(game.Players:GetChildren()) do -stuff end wait(1) end
instead of putting the wait INSIDE the player, we use a for loop - inside that for loop, we cycle through the players
makes sense?
|
|
|
| Report Abuse |
|
|
Xaerium
|
  |
| Joined: 25 Apr 2009 |
| Total Posts: 126 |
|
|
| 22 May 2015 09:04 PM |
Yes, but if inside of that I put this: wait(1) i = 1+1 v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[.]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[..]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[...]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[]")
it will still need to wait in-order for the player loop to be finished. |
|
|
| Report Abuse |
|
|
|
| 22 May 2015 09:06 PM |
function Announcement(Title,LoadTime) for _,v in pairs (game.Players:GetPlayers())do coroutine.resume(coroutine.create(function() if LoadTime ~= nil then v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[]") v.PlayerGui.NotificationGui.Announcement.Visible = true for i = 1,LoadTime do wait(1) i = 1+1 v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[.]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[..]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[...]") wait(1) v.PlayerGui.NotificationGui.Announcement.Text.Text = (Title.."[]") end else v.PlayerGui.NotificationGui.Announcement.Text.Text = Title v.PlayerGui.NotificationGui.Announcement.Visible = true wait(5) end v.PlayerGui.NotificationGui.Announcement.Visible = false end)) end end return Announcement |
|
|
| Report Abuse |
|
|
|
| 22 May 2015 09:10 PM |
my god you really don't understand
just use that guy's script |
|
|
| Report Abuse |
|
|
Xaerium
|
  |
| Joined: 25 Apr 2009 |
| Total Posts: 126 |
|
| |
|