Pop in frame not working

So I created this script so that the frame can fly in but it does not work
Script:

script.Parent.MouseButton1Click:Connect(function()
	local GamePassShop = script.Parent.Frame
	GamePassShop:TweenPosition(UDim2.new(0.272, 0,0.181, 0), "Out", "Bounce",1,true)
end)

But it does not seem to take the Frame and this is the frame
image
I tried renaming it but it does not work

2 Likes

Try this

local GamePassShop = script.Parent.Parent.Frame
1 Like

Thanks man appreciate the help

1 Like

Thanks but I came across another problem same script but with the closing animation

script.Parent.MouseButton1Click:Connect(function()
	local GamePassShop = script.Parent.Parent
	GamePassShop:TweenPosition(UDim2.new(0.272, 0,0.181, 0), "Out", "Bounce",1,true)
end)

I think you forgot to type .Frame at the end

local GamePassShop = script.Parent.Parent.Frame

If you are trying to close the gui, make sure the tween position is different from the first one, so it actually moves the gui somewhere else

Ya I tried that but it tells Frame is not a valid member

Ok so I should change the position value in this line right?

GamePassShop:TweenPosition(UDim2.new(0.272, 0,0.181, 0), "Out", "Bounce",1,true)

Is this the same script like the first one?

Yeah, change the position there

I also suggest to declare the GamePassShop variable at the start of the script, so you don’t have to create a new variable each time you press the button

nope I just added another localscript in the CloseButton

Can you show where the close button is located?

It is located here:
image

local GamePassShop = script.Parent.Parent

This should work. Make sure you change the position, because if its same as the first one, it will just stay in one place

local button = script.Parent
local GamePassShop = script.Parent.Parent:WaitForChild("Frame")

button.MouseButton1Click:Connect(function()
	GamePassShop:TweenPosition(UDim2.new(0.272, 0,0.181, 0), "Out", "Bounce", 1, true)
end)

You shouldn’t be redeclaring a constant (a variable of which its stored value, in this case reference to some instance, never changes), this is for the first script (opening button).

local button = script.Parent
local GamePassShop = script.Parent.Parent

button.MouseButton1Click:Connect(function()
	GamePassShop:TweenPosition(UDim2.new(0.272, 0,0.181, 0), "Out", "Bounce", 1, true)
end)

This is for the second script (closing button).

I presume the local script inside the close button is handling the button itself.