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: Coroutines

Previous Thread :: Next Thread 
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
27 Dec 2013 09:15 AM
I don't get how to use coroutines... How come whenever I use it, it just runs through the function so fast?
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
27 Dec 2013 09:19 AM
Bump... Help?
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
27 Dec 2013 09:28 AM
Coroutines don't stop the script.
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
27 Dec 2013 09:33 AM
Here's my entire script. It just keeps running... I don't know why.

___________________________________________________________________________

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

--------------------------------------------
function WaitForGame()
for i,v in pairs(game.Players:GetChildren()) do
coroutine.resume(coroutine.create(function()
local gstuff = v.PlayerGui.GameStuff
local dplay = gstuff.Display
local txt = "Waiting for the next game: "
for i = 1,string.len(txt),1 do
dplay.Text = string.sub(txt,1,i)
wait()
end
gstuff.Countdown.Visible = true
for b = (waittime),1,-1 do
gstuff.Countdown.Text = b
wait(1)
end
wait(waittime)
gstuff.Countdown.Visible = false
for a = 0,1,0.1 do
dplay.TextTransparency = a
wait()
end
dplay.Text = ""
dplay.TextTransparency = 0
end))
end
end

function StartingTime()
for i,v in pairs(game.Players:GetChildren()) do
coroutine.resume(coroutine.create(function()
local gstuff = v.PlayerGui.GameStuff
local dplay = gstuff.Display
local txt = "Starting in: "
for i = 1,string.len(txt),1 do
dplay.Text = string.sub(txt,1,i)
wait()
end
gstuff.Countdown.Visible = true
for b = (starttime),1,-1 do
gstuff.Countdown.Text = b
wait(1)
end
wait(starttime)
gstuff.Countdown.Visible = false
for a = 0,1,0.1 do
dplay.TextTransparency = a
wait()
end
dplay.Text = ""
dplay.TextTransparency = 0
end))
end
end

function TEXT(txthere)
for i,v in pairs(game.Players:GetChildren()) do
coroutine.resume(coroutine.create(function()
local gstuff = v.PlayerGui.GameStuff
local dplay = gstuff.Display
for i = 1,string.len(txthere),1 do
dplay.Text = string.sub(txthere,1,i)
wait()
end
wait(timebetweentxt)
for a = 0,1,0.1 do
dplay.TextTransparency = a
wait()
end
dplay.Text = ""
dplay.TextTransparency = 0
end))
end
end

function ModeTXT()
for i,v in pairs(game.Players:GetChildren()) do
coroutine.resume(coroutine.create(function()
v.PlayerGui.GameStuff.Game.GameMode.Text = "Game Mode: "..script.Mode.Value
end))
end
end

function MapTXT()
for i,v in pairs(game.Players:GetChildren()) do
coroutine.resume(coroutine.create(function()
v.PlayerGui.GameStuff.Game.Map.Text = "Map: "..script.Map.Value
end))
end
end

function generateMap()
local RandomMap = map[math.random(1,#map)]
local RandomMode = mode[math.random(1,#mode)]
script.Map.Value = RandomMap
script.Mode.Value = RandomMode
end

function GameStart()
for i,v in pairs(game.Players:GetChildren()) do
coroutine.resume(coroutine.create(function()
generateMap()
local maps = game.Lighting.Maps:FindFirstChild(script.Map.Value)
local modes = game.Lighting.Modes:FindFirstChild(script.Mode.Value)
local gstuff = v.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."
----------------------------------
WaitForGame()
----------------------------------
TEXT(txt1,txt)
----------------------------------
ModeTXT()
TEXT(txt2,txt)
----------------------------------
TEXT(txt3,txt)
----------------------------------
MapTXT()
TEXT(txt4,txt)
----------------------------------
if maps:FindFirstChild("Image") ~= nil then
gstuff.Game.Background.MapImage.Image = maps.Image
end
----------------------------------
TEXT(txt5,txt)
----------------------------------
StartingTime()
----------------------------------
TEXT("That was just a test... LOL.",txt)
return
end))
end
end
--------------------------------------------

repeat wait() for i,v in pairs(game.Players:GetChildren()) do coroutine.resume(coroutine.create(function() v.PlayerGui.GameStuff.Display.Text = "Waiting for at least 2 players to join..." end)) end until #game.Players:GetChildren() > 1
GameStart()
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
27 Dec 2013 09:58 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