I am new to here, I'm also a beginner in Lua. I know something about Roblox Studio though. But how do I hide a scrolling frame with a button as the frame's child? I've made some rules by scrolling frame and "I agree" button in it. I want the rules to hide when button is clicked.
I tried
local button = script.Parent
local menu = script.Parent.Parent.Parent
local function onButtonClicked()
if menu.Visible then
menu.Visible = false
else
menu.Visible = true
end
end
button.MouseButton1Down:Connect(onButtonClicked)
and it resulted with nothing.
If the button is a direct child of the scrolling frame you're going up one parent too much.
It should be this:
local menu = script.Parent.Parent
If that's not it, you might have accidentally disabled your script.
I've recreated your scenario in my own studio and your code works fine, see the images and link to a short video below.
Since your script works just fine for me, it might not work for you because you disabled it. To enable it, right-click the script and select "Enable scripts".
(As per your current code)
See the result here (gyazo).
Hopefully, this resolves your issue.