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
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
| |
|
| 27 Dec 2013 09:28 AM |
| Coroutines don't stop the script. |
|
|
| Report Abuse |
|
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
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
| |