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

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

Asked by 3 years ago
Edited 3 years ago

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)
0
:WaitForChild() sngnn 274 — 3y
0
Where? Braftedr 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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

Ad

Answer this question