l0lzz
|
  |
| Joined: 05 Dec 2009 |
| Total Posts: 1529 |
|
|
| 17 Aug 2011 05:00 PM |
I'm new to coroutines how to I make this only put 1 Gui in each player? Right now I just keeps cloning the Gui's into all the players. Also, is the coroutine.yield() part right? Will it run again if 3 or more people come into the server again?
Gui = game.Lighting.RaidGui DB = false
teammems = 0 game.Players.ChildAdded:connect(function(a) if a.TeamColor == BrickColor.new("Bright red") then teammems = teammems + 1 print(teammems) end end)
game.Players.PlayerRemoving:connect(function(Player) if Player.TeamColor == BrickColor.new("Bright red") then teammems = teammems - 1 end end)
while wait(1) do if teammems >= 3 then wait() Players = game.Players:GetChildren() for i = 1,#Players do coroutine.resume(coroutine.create(function() local G = Gui:Clone() local G2 = Gui:Clone() G.Parent = Players[i].PlayerGui G2.Parent = game.StarterGui G.TextButton:TweenPosition(UDim2.new(0,225,0,200),"Out","Sine",1,false,nil) G2.TextButton:TweenPosition(UDim2.new(0,225,0,200),"Out","Sine",1,false,nil) wait(5) G.TextButton:TweenPosition(UDim2.new(0,0,0,0),"Out","Sine",1,false,nil) G2.TextButton:TweenPosition(UDim2.new(0,0,0,0),"Out","Sine",1,false,nil) wait(.5) G.TextButton:TweenSize(UDim2.new(0,350,0,50),"Out","Sine",1,false,nil) G2.TextButton:TweenSize(UDim2.new(0,350,0,50),"Out","Sine",1,false,nil) G.TextButton.Text = "Raid In Progress!" G2.TextButton.Text = "Raid In Progress!" if teammems <= 2 then coroutine.yield() G:Remove() G2:Remove() end end)) end end end |
|
|
| Report Abuse |
|
|
l0lzz
|
  |
| Joined: 05 Dec 2009 |
| Total Posts: 1529 |
|
| |
|
l0lzz
|
  |
| Joined: 05 Dec 2009 |
| Total Posts: 1529 |
|
| |
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 17 Aug 2011 05:28 PM |
I would say, if I read your post right. you would check if a GUI is nil, and if it is you clone one into their playergui.
if game.Players[i].PlayerGui:FindFirstChild(GUI.Name) == nil then end
Something along that line, but what I interpreted your post as was...
More than one GUI is getting copied into each player, How can I make it so only one GUI gets cloned into the player.
Correct me if I am wrong. |
|
|
| Report Abuse |
|
|
l0lzz
|
  |
| Joined: 05 Dec 2009 |
| Total Posts: 1529 |
|
|
| 17 Aug 2011 05:29 PM |
| Yes that is whats happening. I'll try that. |
|
|
| Report Abuse |
|
|
l0lzz
|
  |
| Joined: 05 Dec 2009 |
| Total Posts: 1529 |
|
|
| 17 Aug 2011 05:49 PM |
Now I'm having the same problem I had before I added the coroutine. It will only clone the Gui to one player.....
New Script:
Gui = game.Lighting.RaidGui DB = false
teammems = 0 game.Players.ChildAdded:connect(function(a) if a.TeamColor == BrickColor.new("Bright red") then teammems = teammems + 1 print(teammems) end end)
game.Players.PlayerRemoving:connect(function(Player) if Player.TeamColor == BrickColor.new("Bright red") then teammems = teammems - 1 end end)
while wait(1) do if teammems >= 3 then wait() Players = game.Players:GetChildren() for i = 1,#Players do coroutine.resume(coroutine.create(function() if game.StarterGui:FindFirstChild("RaidGui") == nil then local G2 = Gui:Clone() local G = Gui:Clone() G.Parent = Players[i].PlayerGui G2.Parent = game.StarterGui G.TextButton:TweenPosition(UDim2.new(0,225,0,200),"Out","Sine",1,false,nil) G2.TextButton:TweenPosition(UDim2.new(0,225,0,200),"Out","Sine",1,false,nil) wait(5) G.TextButton:TweenPosition(UDim2.new(0,0,0,0),"Out","Sine",1,false,nil) G2.TextButton:TweenPosition(UDim2.new(0,0,0,0),"Out","Sine",1,false,nil) wait(.5) G.TextButton:TweenSize(UDim2.new(0,350,0,50),"Out","Sine",1,false,nil) G2.TextButton:TweenSize(UDim2.new(0,350,0,50),"Out","Sine",1,false,nil) G.TextButton.Text = "Raid In Progress!" G2.TextButton.Text = "Raid In Progress!" if teammems <= 2 then coroutine.yield() G:Remove() G2:Remove() end end end)) end end end |
|
|
| Report Abuse |
|
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 17 Aug 2011 05:56 PM |
Hmm, Try making a new coroutine then referring to that function? Remove the current yield? So i would say...
coroutine.new(gui()
coroutine.yield(gui())
end)
Or something of that sort? |
|
|
| Report Abuse |
|
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 17 Aug 2011 05:57 PM |
| I will look at your code and see what might be wrong. |
|
|
| Report Abuse |
|
|
l0lzz
|
  |
| Joined: 05 Dec 2009 |
| Total Posts: 1529 |
|
|
| 17 Aug 2011 05:57 PM |
| Huh? I don't know that much about coroutines. Explain more please. |
|
|
| Report Abuse |
|
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 17 Aug 2011 06:00 PM |
| @ 2 posts above, Ignore it. |
|
|
| Report Abuse |
|
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 17 Aug 2011 06:01 PM |
| I was just guessing, but didn't see your if statement. |
|
|
| Report Abuse |
|
|
l0lzz
|
  |
| Joined: 05 Dec 2009 |
| Total Posts: 1529 |
|
|
| 17 Aug 2011 06:02 PM |
| We need some more people to help me with this, Always when I wanted help with this script, I get one person trying to help me. |
|
|
| Report Abuse |
|
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 17 Aug 2011 06:02 PM |
if game.Players[i].PlayerGui:FindFirstChild("RaidGui") == nil then
Try that, It checks each individual player. |
|
|
| Report Abuse |
|
|
l0lzz
|
  |
| Joined: 05 Dec 2009 |
| Total Posts: 1529 |
|
| |
|
l0lzz
|
  |
| Joined: 05 Dec 2009 |
| Total Posts: 1529 |
|
| |
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 17 Aug 2011 06:09 PM |
No problem :)
Makes me feel accomplished more than you. |
|
|
| Report Abuse |
|
|