generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: IS there a way to get ALL players at once... [READ]

Previous Thread :: Next Thread 
Swordphin123 is not online. Swordphin123
Joined: 09 Apr 2008
Total Posts: 5234
06 Dec 2011 02:33 PM
I'm familar with pairs and ipairs, and I use them daily. But, somethings are hard to code with. Like if I do this:

for _,players in pairs(game.Players:GetPlayers()) do
wait(3)
end

This will get the players every 3 second. If I do this:

for _,players in pairs(game.Players:GetPlayers()) do
m = Instance.new("Message", players.PlayerGui)
m.Text = "Test"
wait(8) ----WAITS 8 SECONDS
m.Parent = nil
end

This, won't work the way its suppose too. It usually repeats this "Test" message to every player REPEATLY to how many players are in total in the server, get my idea?

Like, lets say, there are 3 players. This message will repeat 3 times and waits 8 seconds before giving the message to another player, for every player counted in the server because, there are 3 players in total.

My question is, are there any way to get ALL the players, and by any means, only show the above contents at the SAME time, no delays, and only runs the things ONCE? Get my drift?

I might had not explained it clearly, but this is also confusing as well. It might include a lot of planning and logic (well for me, yes).
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
06 Dec 2011 02:36 PM
for _,players in pairs(game.Players:GetPlayers()) do
  coroutine.resume(coroutine.create(function()
    m = Instance.new("Message", players.PlayerGui)
    m.Text = "Test"
    wait(8) ----WAITS 8 SECONDS
    m.Parent = nil
  end))
end


Maybe?
Report Abuse
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
06 Dec 2011 02:39 PM
Or here's a way without coroutine:

for _,v in pairs(game.Players:GetPlayers()) do
m=Instance.new("Message",v.Character)
m.Text="Text"
end
wait(8)
m.Parent=nil
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
06 Dec 2011 02:42 PM
@Penguine
That will only set the last message's parent to nil.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
06 Dec 2011 02:42 PM
@Penguine
How is that any different from the original?
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
06 Dec 2011 02:42 PM
Pretty much the same thing as using a coroutine, but simpler for newer scripters.

for _,v in pairs(game.Players:GetPlayers()) do
local msg = Instance.new("Message", v.PlayerGui)
m.Text="Test"
game:GetService("Debris"):AddItem(msg, 8)
end



"I WILL GIVE YOU BACON." - Deadmau5
~Scarfacial
Report Abuse
Swordphin123 is not online. Swordphin123
Joined: 09 Apr 2008
Total Posts: 5234
06 Dec 2011 02:42 PM
@Spect

And yours will spam the player's screen.
Report Abuse
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
06 Dec 2011 02:45 PM
oh wait sry i messed up. you could do another for loop to remove the message.
Report Abuse
Swordphin123 is not online. Swordphin123
Joined: 09 Apr 2008
Total Posts: 5234
06 Dec 2011 02:46 PM
@Scar

Thanks, seems to be the right one.

@Spect

Wups, I changed something to make it spam. Yea, your script works also fine.

Thanks all, I get the drift.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
06 Dec 2011 03:11 PM
If you want to practice with tables even more, you could do something like this:


local messages = {};
for _, v in pairs(game.Players:GetPlayer()) do
    table.insert(messages, Instance.new("Message", v.PlayerGui));
    messages[_].Text = "Test";
end
wait(5);
for _, v in pairs(messages) do
    v.Parent = nil;
end





Cheers,
-- AFF
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
06 Dec 2011 03:12 PM
Of course, that's assuming you use the GetPlayers method instead of GetPlayer...
>_<


Cheers,
-- AFF
Report Abuse
Swordphin123 is not online. Swordphin123
Joined: 09 Apr 2008
Total Posts: 5234
06 Dec 2011 03:23 PM
GetPlayers and GetPlayer had a difference?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
06 Dec 2011 03:23 PM
GetPlayer doesn't exits. ;D


Cheers,
-- AFF
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
06 Dec 2011 03:24 PM
Exist*

I cannot type anymore ....


Cheers,
-- AFF
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image