TextButton trouble

hi, it’s me again,
I’m not very good at scripting
why this textbutton still visible in next frame? ( i want it to be just in the main menu frame not in tracks, the reazon is not in the main menu frame is that it doesnt work there)
Images:



image

the textbutton script:
local Button = script.Parent

Frame = script.Parent.Parent.Tracks —Enter Name Of Frame

function onClick()

if Frame.Visible == false then

Frame.Visible = true

elseif Frame.Visible == true then

Frame.Visible = false

end

end

Button.MouseButton1Click:connect(onClick)

How can i fix this?

thanks

The TextButton isn’t inside of the frame, so it’s not affect by the change in the frame’s visibility. You should either put the TextButton inside the frame, or also toggle the buttons Visible property with the frame.

but when I put it inside it doesn’t work, I mean I click it and nothing happens

When you move the TextButton, are you updating the Button variable?