Why is this script not working?

Hello, I made this script that is supposed to work like this:
When the player clicks the “Toggle” ImageButton, the script needs to open the “Frame” and make it visible, but when I try playing an error pops up in the output:

Frame is not a valid member of ScrollingFrame “Players.AlexMastersGamers.PlayerGui.CoinGUI.Frame.Holder”

image

Below I’m leaving the script:

script.Parent.MouseButton1Click:Connect(function()
	
end)
	script.Parent.Parent.Frame.Visible = false
	

Any ideas?

Thanks in advance to anyone that tries to help :slight_smile:

Maybe this happens because the code is in the local script in the button named “100”

Yeah, I’ve just noticed that lol, but when I put the script in “LocalScript” in Toggle nothing happens, not even an error and no GUI pops up

It’s because you set the visible property to false. Try this:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent:WaitForChild("Frame").Visible = true
end)
	
1 Like

Works now! Thank you very much!

1 Like

Just trying it out now and it doesn’t seem to close when I click the “Toggle” button again

Do this:

local isOpen = false

script.Parent.MouseButton1Click:Connect(function()
    if isOpen == false then
        isOpen = true
    	script.Parent.Parent:WaitForChild("Frame").Visible = true
    elseif isOpen == true then
        isOpen = false
        script.Parent.Parent:WaitForChild("Frame").Visible = false 
    end
end)

Yup, this works now :sweat_smile:

Sorry for the many issues and requests

1 Like