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: Help? Confused about loops.

Previous Thread :: Next Thread 
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
26 Dec 2013 10:31 AM
So.. I'm trying to make a game that loops forever. But it doesn't work. When the server starts, only I see the GUI pop up, and any new joiners won't.

For example:

while wait() do
plr = game.Players:GetChildren()
for i = 1,#plr do
script.GUI:Clone().Parent = plr[i].PlayerGui
wait(30)
plr[i].PlayerGui.GUI:remove()
wait(10)
end

When new joiners come, the script doesn't run for them... Help?
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
26 Dec 2013 10:32 AM
while wait() do
to;
game.Players.ChildAdded:connect(function()
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
26 Dec 2013 10:34 AM
What if it's like a minigame script? Like, while the game is running and someone joins, it would say "Waiting for two or more players.." when there is already another player there. And the other player is already in the minigame. How will we be able to make new joiners have the same GUI as the one who was already there?
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
26 Dec 2013 10:35 AM
Here's the full script:

_____________________________________________________________________________

map = {"Lakes","Lava","Rocky Mountains"}
mode = {"All For One","Free For All","Team Hunt"}
waittime = 30
starttime = 5

--------------------------------------------

function WaitForGame(plr)
local gstuff = plr[i].PlayerGui.GameStuff
local txt = gstuff.Display
local thetxt = "Waiting for the next game: "
for b = 1,string.len(thetxt),1 do
txt.Text = string.sub(thetxt,1,b)
wait()
end
for v = (waittime),1,-1 do
txt.Text = "Waiting for the next game: "..v
wait(1)
end
for a = 0,1,0.1 do
txt.TextTransparency = a
wait()
end
txt.Text = ""
txt.TextTransparency = 0
end

function GameStart(plr)
local RandomMap = map[math.random(1,#map)]
local RandomMode = mode[math.random(1,#mode)]
local maps = game.Lighting.Maps:FindFirstChild(RandomMap)
local modes = game.Lighting.Modes:FindFirstChild(RandomMode)
local gstuff = plr[i].PlayerGui.GameStuff
local txt = gstuff.Display
local txt1 = "The game mode has been selected."
local txt2 = "The game mode for this round will be '"..modes.Name.."'"
local txt3 = "The map has been selected."
local txt4 = "The map for this round will be '"..maps.Name.."'"
local txt5 = "The game is about to start."
local txt6 = "Starting in: "
--------------------------------------------
for b = 1,string.len(txt1),1 do
txt.Text = string.sub(txt1,1,b)
wait()
end
wait(5)
for a = 0,1,0.1 do
txt.TextTransparency = a
wait()
end
txt.Text = ""
txt.TextTransparency = 0
----------------------------------
for b = 1,string.len(txt2),1 do
txt.Text = string.sub(txt2,1,b)
wait()
end
gstuff.Game.GameMode.Text = "Game Mode: "..modes.Name
wait(5)
for a = 0,1,0.1 do
txt.TextTransparency = a
wait()
end
txt.Text = ""
txt.TextTransparency = 0
----------------------------------
for b = 1,string.len(txt3),1 do
txt.Text = string.sub(txt3,1,b)
wait()
end
wait(5)
for a = 0,1,0.1 do
txt.TextTransparency = a
wait()
end
txt.Text = ""
txt.TextTransparency = 0
----------------------------------
for b = 1,string.len(txt4),1 do
txt.Text = string.sub(txt4,1,b)
wait()
end
gstuff.Game.Map.Text = "Map: "..maps.Name
wait(5)
for a = 0,1,0.1 do
txt.TextTransparency = a
wait()
end
txt.Text = ""
txt.TextTransparency = 0
----------------------------------
if maps:FindFirstChild("Image") ~= nil then
gstuff.Game.Background.MapImage.Image = maps.Image
end
----------------------------------
for b = 1,string.len(txt5),1 do
txt.Text = string.sub(txt5,1,b)
wait()
end
wait(5)
for a = 0,1,0.1 do
txt.TextTransparency = a
wait()
end
txt.Text = ""
txt.TextTransparency = 0
----------------------------------
for b = 1,string.len(txt6),1 do
txt.Text = string.sub(txt6,1,b)
wait()
end
for _ = (starttime),1,-1 do
txt.Text = "Starting in: ".._
wait(1)
end
----------------------------------
for b = 1,string.len("That was just a test... LOL."),1 do
txt.Text = string.sub("That was just a test... LOL.",1,b)
wait()
end
wait(10)
for a = 0,1,0.1 do
txt.TextTransparency = a
wait()
end
txt.Text = ""
txt.TextTransparency = 0
end

--------------------------------------------

repeat wait() until #game.Players:GetChildren() > 1
while wait() do
local plr = game.Players:GetChildren()
for i = 1,#plr do
WaitForGame(plr)
GameStart(plr)
end
end
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
26 Dec 2013 10:43 AM
How do I make it so that all the new joiners will be able to see the same thing as the others? Like how do the people who make minigames do it? Loops?
Report Abuse
Azureous is not online. Azureous
Joined: 29 Jan 2012
Total Posts: 25287
26 Dec 2013 10:44 AM
Use the PlayerAdded event and :Clone() it into the PlayerGui.
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
26 Dec 2013 10:47 AM
But the GUI is already in the PlayerGui. And if I clone it into the PlayerGui, won't it start at the beginning of the script? Then the new joiners script will start at the beginning.
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
26 Dec 2013 10:57 AM
Oh. I know the problem.
IF we do something like this:

for a = 0,1,0.1 do
txt.TextTransparency = a
wait()
end

It'll run 1 person at a time... How can I make it so that it runs at the same time for each person?
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
26 Dec 2013 11:01 AM
Bump...
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