alecspw
(ThatAlecs)
April 25, 2022, 8:12am
#1
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”
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
Maybe this happens because the code is in the local script in the button named “100”
alecspw
(ThatAlecs)
April 25, 2022, 8:16am
#3
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
alecspw
(ThatAlecs)
April 25, 2022, 8:19am
#5
Works now! Thank you very much!
1 Like
alecspw
(ThatAlecs)
April 25, 2022, 8:23am
#6
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)
alecspw
(ThatAlecs)
April 25, 2022, 8:26am
#8
Yup, this works now
Sorry for the many issues and requests
1 Like