|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 24 Dec 2011 08:52 AM |
| Did you read my post? Without loop? |
|
|
| Report Abuse |
|
|
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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 24 Dec 2011 09:26 AM |
| Agree with itunes. He expects to make a script without loops or functions. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 24 Dec 2011 09:48 AM |
| Yes, i am happy now. ^_^ Thanks! |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|