So I keep getting an error telling me "Main" is not part of the playergui. I added a line of code to the main script to tell it to wait until it is but it still gives me that error each time. Its like the script is running faster than the startergui can put the gui "Main" in the player
001 | local PlayerBase = game:GetService( "Players" ) |
002 | PlayerBase.PlayerAdded:connect( function (PlayerUI) |
003 | repeat wait() until PlayerUI.PlayerGui:WaitForChild( "Main" ) |
004 | end ) |
005 |
006 |
007 | --// Tables |
008 |
009 | winners = { } |
010 |
011 | --// Modules |
012 |
013 | Settings = require (script.Settings) |
014 |
015 | --// Game Variables |
I see the problem, when you are calling the PlayerAdded event, Lua will execute the code inside of that event and nothing else. Lets say you want to add a WaitForChild()
code in the PlayerAdded event (which you did lol) it will only wait for the child and move on, not passing it on to the that script. So I would advice you to change every .Main
to :WaitForChild("Main")
.
Example;
1 | Player.PlayerGui:WaitForChild( "Main" ) |
2 | --or-- |
3 | Player [ i ] .PlayerGui:WaitForChild( "Main" ) --the [i] depends if you are using a for loop |
Hope this helped!
TIP: I would advise to hold Ctrl + H (for Windows, but for Mac; Command + H), a frame will appear on the top right hand corner of your screen and you will tell why I said that ;)!