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

MainFrame is not a valid member of Frame when im making a Fading Effect?

Ok so im making a main menu and when you ckick the play button in the main menu the main menu starts to fade away using Background Transperency, However I have ran into a slight problem, my main menu frame that I called "MainFrame" says its not a valid member of Frame

BTW THIS IS IMPORTANT IM JUST TRYING TO FIRST USE BACKGROUND TRANSPERENCY SO THATS WHY THE VALUE IS AT 1

here is what it says: 14:20:20.858 - MainFrame is not a valid member of Frame

Here is my Script:

local LoadingScreenGui = script.Parent
local MainFrame = LoadingScreenGui.MainFrame
local PlayButton = MainFrame.PlayButton

PlayButton.MouseButton1Up:Connect(function()
	
	MainFrame.BackgroundTransparency = 1
end)

2 comments

0

:WaitForChild()

0

Where?

1 answer

Its probably in the wrong directory but either way, when working with UI you should always use the wait for child function, per example:

local MainFrame = script.Parent:WaitForChild('MainFrame');

This forces the code to wait until that object exists before declaring it and moving on with the rest of the script, if it gives a timeout error it means the object simply never appeared and its probably on a different path

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