200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 18 Apr 2012 02:30 PM |
I just thought about something, I've been using shared to reference functions cross-script, and some of the functions I use with shared are inside scripts that are children of StarterGui's, which will be inside every player once the game starts, and if I have to, for example, show a certain Gui, in said functions, I'll usually just do something like script.parent.Frame.Visible = true
So, say I want to call a function: Player.PlayerGui.ScreenGui.TextLabel.Script and 'Script' script is: function dosomething(text) script.Parent.Visible = true script.Parent.Text = text end
shared.dosomething = dosomething (end of script)
What would happen? Would all players that have that Gui now have it visible with that text?
Or would it somehow only happen to the player that the script that called shared.dosomething was handling currently?
Just something I was thinking about. :P |
|
|
| Report Abuse |
|
|
Aaaboy97
|
  |
| Joined: 05 Apr 2009 |
| Total Posts: 6612 |
|
|
| 18 Apr 2012 02:46 PM |
It would not work how you expect
script does not change based on the function that's calling it
HOWEVER, you could do this:
shared.dosomething = function(Script, text) Script.Parent.Visible = true Script.Parent.Text = text end
Notice how you call it like this: shared.dosomething(script, "Hello world!")
Since you pass the variable "script" into the global function, this will work how you expected it to. |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 18 Apr 2012 02:51 PM |
(^Lolsubject)
I see, so it's probably best to just not have global functions inside PlayerGui's. :P
Thanks. |
|
|
| Report Abuse |
|
|