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

Frame is not a valid member of Frame?

Asked by 5 years ago
Edited 5 years ago

the thing is, I write code, how I write it...I've received this error: Frame is not a valid member of Frame. What am I to do? I'm still new to coding, and I'm not sure what the mistake is.here is the script:

local frame = script.Parent.Parent.Frame
local open = script.Parent.Parent.Open
local blur = Instance.new("BlurEffect",game.Workspace.CurrentCamera)
blur.Size = 0

script.Parent.MouseButton1Click:connect(function()
    if open.Value == false then
        frame:TweenPosition(UDim2.new(0.5,-250,0.5,-175),"Out","Quint",1,true)
        for i = 0,10,1 do
            wait()
            blur.Size = i
        end
        open.Value = true
    elseif open.Value == true then
        frame:TweenPosition(UDim2.new(0.5,-250,-0.5,-175),"Out","Quint",1,true)
        for i = 10,0,-1 do
            wait()
            blur.Size = i
        end
        open.Value = false
    end
end)

I need the button to close the store menu, but that doesn't happen. but when I press the "open shop" button, then everything perfectly opens and closes, and there is the same script, and everything is normal, what is wrong here?I wrote that the error in 1 line, but no matter what I tried, nothing worked

0
Is the script inside the frame? What's the exact heirarchy of the script and guis? mattscy 3725 — 5y
0
there is no other script inside the frame, there are only other buttons. *What's the exact heirarchy of the script and guis?* - what do you mean? Dux3dizb 4 — 5y
0
He means what does it look like in the explorer, like, the tree, so what is parented to what, etc. Amiaa16 3227 — 5y
0
use WaitForChild / FindFirstChild. V_ChampionSSR 247 — 5y

1 answer

Log in to vote
0
Answered by
T0XN 276 Moderation Voter
5 years ago
Edited 5 years ago

Taking a stab in the dark since I don't exactly know the hierarchy for your GUI, but try adding a WaitForChild() to ensure that "frame" is added. I've made a function for tweening to save some readability.

local frame = script.Parent.Parent.Frame
local open = script.Parent.Parent.Open
local blur = Instance.new("BlurEffect", game.Workspace.CurrentCamera)
blur.Size = 0

local function tweenFrame(tweenIncrement, blurIncrement)
    frame:TweenPosition(UDim2.new(0.5, -250, tweenIncrement, -175), "Out", "Quint", 1, true)
    for i = 0, 10, blurIncrement do
        wait()
        blur.Size = i
    end
    open.Value = not open.Value
end

script.Parent.MouseButton1Click:Connect(function()
    if not open.Value then
        tweenFrame(0.5, 1)
    elseif open.Value then
        tweenFrame(-0.5, -1)
    end
end)
Ad

Answer this question