Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Start GUI not working?

My Start GUI isnt working (output says Frame is not a valid member of ScreenGui, it is!) Script:

--Script by club101coolguy
local Player = game.Players.LocalPlayer
gui = script.Parent.Parent
Frame1 = gui.Frame1
Box = gui.Frame1
Play = gui.Play
Text = gui.TextLabel
local Sound = Instance.new("Sound", gui)
Sound.SoundId = "http://www.roblox.com/asset/?id=221235033"
Sound.Pitch = 1
Sound.Volume = 0.7

--Variables and Variable Properties

Sound:Play()

function MouseEnterPlayButton()
	Play.FontSize = "Size48"
end

function MouseLeftPlayButton()
	Play.FontSize = "Size36"
end
Play.MouseEnter:connect(MouseEnterPlayButton)
Play.MouseLeave:connect(MouseLeftPlayButton)

--Makes chat Play Button bigger when a mouse hovers.

function PlayGame()
	Box:Destroy()
	Play:Destroy()
	Sound:Stop()
	Text:Destroy()
end

Play.MouseButton1Down:connect(PlayGame)
--When a Player clicks on Play, Music stops and GUIs dissapear.



1 comment

0

Where is the script?

1 answer

✓ Accepted answer

I believe your problem is just that the script isn't giving the Frame enough time to load into the game.


To fix this, we can simply use the :WaitForChild function. This waits until the given argument is loaded into the game for the script to continue. So, let's try it in your script:

--Script by club101coolguy
local Player = game.Players.LocalPlayer
gui = script.Parent.Parent
Frame1 = gui:WaitForChild("Frame1")
Box = gui:WaitForChild("Frame1")
Play = gui:WaitForChild("Play")
Text = gui:WaitForChild("TextLabel")
local Sound = Instance.new("Sound", gui)
Sound.SoundId = "http://www.roblox.com/asset/?id=221235033"
Sound.Pitch = 1
Sound.Volume = 0.7

--Variables and Variable Properties

Sound:Play()

function MouseEnterPlayButton()
    Play.FontSize = "Size48"
end

function MouseLeftPlayButton()
    Play.FontSize = "Size36"
end
Play.MouseEnter:connect(MouseEnterPlayButton)
Play.MouseLeave:connect(MouseLeftPlayButton)

--Makes chat Play Button bigger when a mouse hovers.

function PlayGame()
    Box:Destroy()
    Play:Destroy()
    Sound:Stop()
    Text:Destroy()
end

Play.MouseButton1Down:connect(PlayGame)
--When a Player clicks on Play, Music stops and GUIs dissapear.

So, now I believe it should work correctly. As you can see, I used it on lines 4-7, just to make sure you have no further loading issues. ######Also, I'm not sure if you noticed, but line 5 is getting the same things as line 4, which is Frame1. Just wanted to let you know just in case that's a mistake, but otherwise, it should all work correctly now.


Anyways, if you have any further problems/questions, please leave a comment below. Hope I helped, and if I did, an up-vote would be appreciated :P

####-Dyler3

2 comments

0

Thanks man! It worked perfectly :)

0

No problem dude, always happy to help :P

This discussion is preserved as it was. New answers, comments, and votes are closed.