Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Start GUI not working?

Asked by
Vid_eo 126
9 years ago

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.



0
Where is the script? xAtom_ik 574 — 9y

1 answer

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

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

0
Thanks man! It worked perfectly :) Vid_eo 126 — 9y
0
No problem dude, always happy to help :P dyler3 1510 — 9y
Ad

Answer this question