Yielding means your code will come to a halt until a function or an execution finishes. On your 3rd line when you do local ScrollingFrame2 = ScreenGui:WaitForChild("ScrollingFrame2"), it won’t run any code past that line until there’s something called ScrollingFrame2 inside of ScreenGui, infinite yield resulting from ScrollingFrame2 never being in ScreenGui, so while in-game (testing in studio) check to see if you’ve mispelled it, if it’s being placed under ScreenGui at all or if your ScrollingFrame2 is being placed elsewhere. It’s a common mistake for beginners to also try and make changes to a player’s or their own UI through StarterGui instead of the player’s gui.
The global Instance is also a table, and is not userdata or an actual instance therefor it does not inherit the :WaitForChild() method, so that’ll also error. (Unless you’ve change Instance)
I’m not sure if that is a troll post considering the following:
But if this is a genuine post, then make sure that an actual ScrollingFrame named “ScrollingFrame2” is added to your ScreeenGui. If you want it to stop waiting after a certain time, you can supply WaitForChild the second timeout argument as a number, not never
Okay, in that case here is a working version of the script, without taking into account your game’s behavior with the child “ScrollingFrame2”
local ScreenGui = script.Parent.ScreenGui
local ScrollingFrame2 = ScreenGui:WaitForChild("ScrollingFrame2", 1)
local Button1 = ScreenGui:WaitForChild("Button1", 1)
Button1.MouseButton1Click:Connect(function() --> I'm guessing this is to toggle the visibility?
ScrollingFrame2.Visible = not ScrollingFrame2.Visible
end)