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 » Scripters
Home Search
 

Re: One player game; need to gather player(NO LOCALSCRIPTS)

Previous Thread :: Next Thread 
CDDogg is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
LilMcManiac is online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
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 is not online. 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 is not online. 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
LilMcManiac is online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
11 Feb 2016 11:28 PM
PlayerGui
Report Abuse
CDDogg is not online. 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 is not online. 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
SwagCuzYolo is not online. SwagCuzYolo
Joined: 31 Oct 2013
Total Posts: 1224
11 Feb 2016 11:32 PM
Why are you trying to do this in the literal worst way possible?
Report Abuse
CDDogg is not online. CDDogg
Joined: 10 Aug 2010
Total Posts: 1233
11 Feb 2016 11:33 PM
nope PlayerGui is still a nil value
Report Abuse
XThane is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
12 Feb 2016 03:21 AM
use :GetPlayers(), not :GetChildren().



#code R+ | local RAP = "431,195"; local robux = "R$32,827"
Report Abuse
DarthStrantax is not online. DarthStrantax
Joined: 31 May 2011
Total Posts: 2610
12 Feb 2016 03:28 AM
local player = game.Players.PlayerAdded:wait()
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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