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: Help with a very stupid error,

Previous Thread :: Next Thread 
Computermaster01 is online. Computermaster01
Joined: 29 May 2012
Total Posts: 369
09 Aug 2014 03:47 AM
This is the line of code that I am getting an error on:
game.Players.PlayerAdded:connect(function(Player)
Text = Player.PlayerGui.Message.Frame.TextLabel.Text
--My game code which I do not want to reveal
end)

This is the output.

02:42:02.102 - Message is not a valid member of PlayerGui



This is how the parenting of the Player gos:

Players>
Player1>
PlayerGui>
Message>
Frame>
TextLabel> (Which has text)


I can't seem to figure out why this is causing an error. Any help is appreciated, thank you.
Report Abuse
Computermaster01 is online. Computermaster01
Joined: 29 May 2012
Total Posts: 369
09 Aug 2014 03:58 AM
Bump
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
09 Aug 2014 04:02 AM
What is 'Message'?
Report Abuse
Computermaster01 is online. Computermaster01
Joined: 29 May 2012
Total Posts: 369
09 Aug 2014 04:04 AM
a ScreenGui
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
09 Aug 2014 04:06 AM
Quickly try this in the command prompt

print(game.Players.Player1.PlayerGui.Message.Name)

It won't fix it, but lemme know if the error is the same.
Report Abuse
Fidgeting is not online. Fidgeting
Joined: 08 Feb 2014
Total Posts: 1193
09 Aug 2014 04:08 AM
:FindFirstChild()
Report Abuse
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
09 Aug 2014 04:08 AM
Its because in online mode, it takes a little bit of time for things to load. In this case, your gui isn't loading fast enough.
Easy way to do it is either use WaitForChild() which I have no clue how to use or do:

local message = Player.PlayerGui:FindFirstChild("Message")

while not message do
message = Player.PlayerGui:FindFirstChild("Message")
wait()
end

Text = message.Frame.TextLabel.Text

This delays the script until message gui has finally loaded in thereby preventing an error
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
09 Aug 2014 04:09 AM
@Above, if its the issue im thinking it is, it still won't work.
Report Abuse
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
09 Aug 2014 04:10 AM
Yeah. You might need to rename the gui other than message then. Or something that isn't the same ClassName as any Object.
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
09 Aug 2014 04:13 AM
Actually that is the issue, since the action fire as soon as a player is added, not when the player loads, it attempts to access a gui that doesn't exist.

Many complex way to do this, just add a wait(3)
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
09 Aug 2014 04:13 AM
wait(3)

game.Players.PlayerAdded:connect(function(Player)
Text = Player.PlayerGui.Message.Frame.TextLabel.Text



end)
Report Abuse
Computermaster01 is online. Computermaster01
Joined: 29 May 2012
Total Posts: 369
09 Aug 2014 04:15 AM
I used find first child and it gave me the same error, also not that this is in Test mode. I have went into online mode to test the entire game but it didn't work.
Report Abuse
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
09 Aug 2014 04:15 AM
No offense or anything but I dont really like using wait() although it does work, it's not exact and the speed isn't the same as using WaitForChild() or my method. These methods are almost instant since usually it only takes an extra millisecond or something to load the gui
Report Abuse
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
09 Aug 2014 04:16 AM
Say if your still getting the error after renaming the gui other than message like MessageGui AND using the way I told you in my first post on the very top of your script.
Report Abuse
Moziderp is not online. Moziderp
Joined: 21 Oct 2013
Total Posts: 1923
09 Aug 2014 04:19 AM
I hope this will work?

game.Players.PlayerAdded:connect(function(Player)
waitFC = Player:WaitForChild(Player.PlayerGui.Message)
if waitFC then
Text = Player.PlayerGui.Message.Frame.TextLabel.Text
-- Your code
end
end)


~~ GG NO RE ~~
Report Abuse
Computermaster01 is online. Computermaster01
Joined: 29 May 2012
Total Posts: 369
09 Aug 2014 04:29 AM
@dan When I used your method I got the error: "Attempted to index a nil Value"

^when I use your method I got: "Message is not a valid member of PlayerGui"

I really don't get it, because i went into game and used the dev console, and got the same error, but I go into test mode and look at the GUI, it is there and loaded, but I still get the same error.
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
09 Aug 2014 04:32 AM
Hey. Just realized this, in the part of the code you didn't show us is where the error could be, Perhaps a typo, incorrect hierarchy, etc.
Report Abuse
Computermaster01 is online. Computermaster01
Joined: 29 May 2012
Total Posts: 369
09 Aug 2014 04:35 AM
This is the entire function that fires when a player is added:

RoundTime = game.ServerStorage.RoundTime.Value

game.Players.PlayerAdded:connect(function(Player)
Message = Player/Player.PlayerGui.MessageGui
Text = Message.Frame.TextLabel.Text
wait(5)
if RoundTime == 0 then
Text = ("Intermission, Time Until Next Round:"..Intermission)
else
Text = ("Round in Progress")
end
end)
Report Abuse
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
09 Aug 2014 04:35 AM
You were supposed to put my code under:

game.Players.PlayerAdded:connect(function(Player)

because then Player wouldn't be defined thereby causing the nil value problem. My code won't cause an error because it either make sure the script doesn't run if it cant find the MessageGui or it works like a charm. (Note: Remember to make sure the Name of the gui is MessageGui AND you replaced the Name Message to MessageGui in the script) (Next time post the line number too)
Report Abuse
dansk is not online. dansk
Joined: 24 Dec 2008
Total Posts: 548
09 Aug 2014 04:36 AM
game.Players.PlayerAdded:connect(function(Player)
local message = Player.PlayerGui:FindFirstChild("Message")
while not message do
message = Player.PlayerGui:FindFirstChild("Message")
wait()
end
Text = message.Frame.TextLabel.Text
end)
Report Abuse
Moziderp is not online. Moziderp
Joined: 21 Oct 2013
Total Posts: 1923
09 Aug 2014 04:37 AM
I made a mistake in the last code, found out what it is happen.

game.Players.PlayerAdded:connect(function(Player)
waitFC = Player.PlayerGui:WaitForChild("Message")
if waitFC then
-- Your code.
end
end)

Heh, sorry. :)

~~ GG NO RE ~~
Report Abuse
Computermaster01 is online. Computermaster01
Joined: 29 May 2012
Total Posts: 369
09 Aug 2014 04:38 AM
btw message = player/playergui was a typo it is a .
Report Abuse
Computermaster01 is online. Computermaster01
Joined: 29 May 2012
Total Posts: 369
09 Aug 2014 04:42 AM
omg i think roblox be hatin' cause I changed the scrip to this:

game.Players.PlayerAdded:connect(function(Player)
message = Player.PlayerGui:WaitForChild("MessageGui")
if message ~= nil then
Text = message.Frame.Text
wait(5)
if RoundTime == 0 then
Text = ("Intermission, Time Until Next Round:"..Intermission)
else
Text = ("Round in Progress")
end
end
end)


That way the message couldn't be nil and the script go on, but now it is giving me the message, but saying that text is not a part frame.
Report Abuse
Computermaster01 is online. Computermaster01
Joined: 29 May 2012
Total Posts: 369
09 Aug 2014 04:42 AM
WAIT I HAVE AN IDEA LET ME TRY SOMETHING
Report Abuse
Computermaster01 is online. Computermaster01
Joined: 29 May 2012
Total Posts: 369
09 Aug 2014 04:45 AM
Welp I fixed the loading problem. Thanks everyone, but there is another problem. The hint is still not working. So does anyone have any help for that?
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