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: Is it possible to do a gui press function for every gui on screen?

Previous Thread :: Next Thread 
GuessWhoGhostIsIt is not online. GuessWhoGhostIsIt
Joined: 17 Sep 2011
Total Posts: 554
23 Dec 2011 11:43 AM
Title. For example, i have 20 guis. And i need to detect click for any from them. How would i do this?

Expecting the answer, how can i do it without creating functions for every single button?
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
23 Dec 2011 11:47 AM
function name_of_function()
--content of function
end

button1.MouseButton1Click:connect(name_of_function)
Report Abuse
GuessWhoGhostIsIt is not online. GuessWhoGhostIsIt
Joined: 17 Sep 2011
Total Posts: 554
24 Dec 2011 06:42 AM
I have at least 20 guis. And i dont know their exact name. Did you at least read my post?
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
24 Dec 2011 07:20 AM
for _,v in pairs(the.location.where.they.are.Frame) do
v.MouseButton1Click:connect(blabla)
end
Report Abuse
GuessWhoGhostIsIt is not online. GuessWhoGhostIsIt
Joined: 17 Sep 2011
Total Posts: 554
24 Dec 2011 08:52 AM
Did you read my post? Without loop?
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
24 Dec 2011 09:04 AM
Better question: Did you read my post?

function a()
print("Click for any button!")
end
for _,v in pairs(the.location.where.they.are.Frame) do
v.MouseButton1Click:connect(a)
end
Report Abuse
itunes89 is not online. itunes89
Joined: 19 Jan 2011
Total Posts: 1957
24 Dec 2011 09:09 AM
Guys stop trying to help this person. He is a jerk.
Report Abuse
GuessWhoGhostIsIt is not online. GuessWhoGhostIsIt
Joined: 17 Sep 2011
Total Posts: 554
24 Dec 2011 09:26 AM
For i, v in pairs - is not that a loop? I am only trying to get the right answer. I am also extremely tired from people coming and giving the first thing they have in their mind...
Report Abuse
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
24 Dec 2011 09:26 AM
Agree with itunes. He expects to make a script without loops or functions.
Report Abuse
GuessWhoGhostIsIt is not online. GuessWhoGhostIsIt
Joined: 17 Sep 2011
Total Posts: 554
24 Dec 2011 09:31 AM
What did i do, that you call me that. BTW, i am sorry for forgetting to tell you about the no loops. And, i want functions, but i think that loops in here will be a bad idea. So, is that any way to do the task without loops?
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
24 Dec 2011 09:46 AM
TITLE: Is it possible to do a gui press function for every gui on screen?

Title. For example, i have 20 guis. And i need to detect click for any from them. How would i do this?

Expecting the answer, how can i do it without creating functions for every single button?



First: Where did you state loops are not allowed?
And WHY are loops not allowed? My script uses a single function for them all.
You're counter-talking yourself.

Anyway, without loops since you prefer that:

function a()
print("Clicked!")
end
local b = 1
local c = where.it.is:GetChildren()
function d()
if #c >= b then
c[b].MouseButton1Down:connect(a)
b = b + 1
end
end
d()


Happy now? I'm afraid it's not much better.
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
24 Dec 2011 09:47 AM
Err sorry, I meant this:

function a()
print("Clicked!")
end
local b = 1
local c = where.it.is:GetChildren()
function d()
if #c >= b then
c[b].MouseButton1Down:connect(a)
b = b + 1
d()
end
end
d()
Report Abuse
GuessWhoGhostIsIt is not online. GuessWhoGhostIsIt
Joined: 17 Sep 2011
Total Posts: 554
24 Dec 2011 09:48 AM
Yes, i am happy now. ^_^ Thanks!
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
24 Dec 2011 09:50 AM
Now elaborate why you prefer it over a loop, since it seems much better.
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
24 Dec 2011 09:54 AM
Guys you Guys are being jerks.
All he wan'ts to know is if thrers a better way.
Gosh.
Now I know why I used to stay away from Scripting Helpers.


~= Pointless siggy. Ujelly? =~
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
24 Dec 2011 09:57 AM
*cough*recursive function==loop*cough*

You can't do it without a loop unless you do it my way and just name them all.
Report Abuse
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
24 Dec 2011 09:59 AM
@poke

We're giving him help that he wont accept. Hes the one being the jerk. He asked for help, we gave it to him and he says that he doesnt want it.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
24 Dec 2011 10:00 AM
I would suggest adding an argument for the button as well.



local Buttons = script.Parent.MyButtons

function StuffToDo(TheButton)
    TheButton.Text = "Click me!"
end
function MoreStuff(TheButton)
    TheButton.Text = "Hover over me!"
end
for _,v in pairs(Buttons:GetChildren()) do
    v.MouseEnter:connect(function() StuffToDo(v) end)
    v.MouseLeave:connect(function() MoreStuff(v) end)
end



Using that kind of setup, adding the button itself to the parameter list, will enable you to edit the button's properties within the StuffToDo and MoreStuff functions.
Report Abuse
dennisvdz is not online. dennisvdz
Joined: 14 Dec 2008
Total Posts: 3710
24 Dec 2011 10:19 AM
@SDuke524: He seems to like that so yea I don't care :P.
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
24 Dec 2011 10:37 AM
@Penguine

Because he wants to know if there is a better way.
Can't you understand?

~= Pointless siggy. Ujelly? =~
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