CDDogg
|
  |
| Joined: 10 Aug 2010 |
| Total Posts: 1233 |
|
|
| 11 Feb 2016 11:05 PM |
this command doesn't work: local p = game.Players:GetChildren()[1]
when later in the script I need this: p.PlayerGUI.q.TextLabel2.Text = "Find The Firewood(COMPLETED)"
console says failed to index because p is a nil value. This wouldn't be a problem if I could use p = game.Players.Localplayer however if this script is made a local script, all the scripts in the game that aren't even directly connected to this one cease to work. |
|
|
| Report Abuse |
|
|
XThane
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 2702 |
|
|
| 11 Feb 2016 11:08 PM |
It's because the script doesn't wait for the player to exist before setting the variable.
~ Who's awesome, you're awesome ~ |
|
|
| Report Abuse |
|
|
XThane
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 2702 |
|
|
| 11 Feb 2016 11:11 PM |
Also, you should never change Guis from a server-script. It lags.
~ Who's awesome, you're awesome ~ |
|
|
| Report Abuse |
|
|
CDDogg
|
  |
| Joined: 10 Aug 2010 |
| Total Posts: 1233 |
|
|
| 11 Feb 2016 11:12 PM |
| The lag is necessary it allows the player time to read the sentence. |
|
|
| Report Abuse |
|
|
CDDogg
|
  |
| Joined: 10 Aug 2010 |
| Total Posts: 1233 |
|
|
| 11 Feb 2016 11:15 PM |
| Also is there any command i can even use? waitforchild obviously won't work because it requires a variable by name. and repeat wait() until also requires an already defined variable |
|
|
| Report Abuse |
|
|
XThane
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 2702 |
|
|
| 11 Feb 2016 11:18 PM |
The lag is bad, because it lags BEFORE even writing the sentence, and it's only around a quarter or half a second.
You can use a repeat loop to wait until the amount of players is 1.
~ Who's awesome, you're awesome ~ |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2016 11:27 PM |
repeat wait() until game.Players.NumPlayers == 1 local p = game.Players:GetPlayers()[1] --other code
I would do this. |
|
|
| Report Abuse |
|
|
CDDogg
|
  |
| Joined: 10 Aug 2010 |
| Total Posts: 1233 |
|
|
| 11 Feb 2016 11:27 PM |
| well i tried your solution and now it fails to index field PlayerGUI. Is playergui not located in player? |
|
|
| Report Abuse |
|
|
CDDogg
|
  |
| Joined: 10 Aug 2010 |
| Total Posts: 1233 |
|
|
| 11 Feb 2016 11:28 PM |
| lil, thats literally what i did before you posted that. |
|
|
| Report Abuse |
|
|
| |
|
CDDogg
|
  |
| Joined: 10 Aug 2010 |
| Total Posts: 1233 |
|
|
| 11 Feb 2016 11:30 PM |
| oh ok, i remember i tried all caps when it failed the first time. I'll change it back and try again. |
|
|
| Report Abuse |
|
|
XThane
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 2702 |
|
|
| 11 Feb 2016 11:30 PM |
It's PlayerGui and you need to use WaitForChild. And again, I don't recommend changing any Guis from the server.
~ Who's awesome, you're awesome ~ |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2016 11:32 PM |
| Why are you trying to do this in the literal worst way possible? |
|
|
| Report Abuse |
|
|
CDDogg
|
  |
| Joined: 10 Aug 2010 |
| Total Posts: 1233 |
|
|
| 11 Feb 2016 11:33 PM |
| nope PlayerGui is still a nil value |
|
|
| Report Abuse |
|
|
XThane
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 2702 |
|
|
| 11 Feb 2016 11:33 PM |
Because you didn't use WaitForChild.
~ Who's awesome, you're awesome ~ |
|
|
| Report Abuse |
|
|
CDDogg
|
  |
| Joined: 10 Aug 2010 |
| Total Posts: 1233 |
|
|
| 11 Feb 2016 11:36 PM |
| oh i see now, and believe it or not this is MORE efficient than the previous method. Now i've made it easier by making each quest a series of values and an unpack able model in lighting all called to render in one script. the previous method was several values and scripts in the GUI and several models both in workspace and lighting for just one quest. This while time consuming just makes it easier to develop when its perfected. |
|
|
| Report Abuse |
|
|
XThane
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 2702 |
|
|
| 11 Feb 2016 11:38 PM |
Storing things in Lighting is an outdated method. Now we have ServerStorage and ReplicatedStorage.
~ Who's awesome, you're awesome ~ |
|
|
| Report Abuse |
|
|
CDDogg
|
  |
| Joined: 10 Aug 2010 |
| Total Posts: 1233 |
|
|
| 11 Feb 2016 11:49 PM |
i haven't done any real developing like this since 2012 so i'm a little old fashioned also i tried wait for child and it doesn't work, here's why:
repeat wait() until game.Players.NumPlayers == 1 local p = game.Players:GetChildren()[1] local g = p:WaitForChild("PlayerGui")
function update_output(property) print("quest one finished") script.Parent.Parent.Q1S.Value = false g.q.TextLabel2.Text = "Find The Firewood(COMPLETED)" wait(1)
I just can't write that any better and the console says waitforchild is a nil value |
|
|
| Report Abuse |
|
|
XThane
|
  |
| Joined: 08 Apr 2009 |
| Total Posts: 2702 |
|
|
| 12 Feb 2016 12:08 AM |
WaitForChild does work. Try using it again to get q. And it's GetPlayers(), not GetChildren()
~ Who's awesome, you're awesome ~ |
|
|
| Report Abuse |
|
|
CDDogg
|
  |
| Joined: 10 Aug 2010 |
| Total Posts: 1233 |
|
|
| 12 Feb 2016 12:38 AM |
| i already fixed it i just need waitforchild to be within the function. |
|
|
| Report Abuse |
|
|
12103net
|
  |
| Joined: 08 Jul 2013 |
| Total Posts: 350 |
|
|
| 12 Feb 2016 12:39 AM |
@xth i'm one of those :children'' guys heh.
for i,v in pairs(whatever:children'') do end
my typing>all efficiency |
|
|
| Report Abuse |
|
|
|
| 12 Feb 2016 03:21 AM |
use :GetPlayers(), not :GetChildren().
#code R+ | local RAP = "431,195"; local robux = "R$32,827" |
|
|
| Report Abuse |
|
|
|
| 12 Feb 2016 03:28 AM |
| local player = game.Players.PlayerAdded:wait() |
|
|
| Report Abuse |
|
|