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

Frame is not a valid member of Frame?

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

4 comments

0

Is the script inside the frame? What's the exact heirarchy of the script and guis?

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?

0

He means what does it look like in the explorer, like, the tree, so what is parented to what, etc.

0

use WaitForChild / FindFirstChild.

1 answer

✓ Accepted answer

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)

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