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 
l0lzz is not online. 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 is not online. l0lzz
Joined: 05 Dec 2009
Total Posts: 1529
17 Aug 2011 05:08 PM
Bump
Report Abuse
l0lzz is not online. l0lzz
Joined: 05 Dec 2009
Total Posts: 1529
17 Aug 2011 05:23 PM
Bumpers
Report Abuse
Riderj is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
17 Aug 2011 06:00 PM
@ 2 posts above, Ignore it.
Report Abuse
Riderj is not online. 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 is not online. 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 is not online. 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 is not online. l0lzz
Joined: 05 Dec 2009
Total Posts: 1529
17 Aug 2011 06:03 PM
Ok, I'll try.
Report Abuse
l0lzz is not online. l0lzz
Joined: 05 Dec 2009
Total Posts: 1529
17 Aug 2011 06:06 PM
YAY, Thanks so much!
Report Abuse
Riderj is not online. 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
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