Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

shop open close button help?

I need help with a shop button that opens up the shop but when clicked again closes the shop. Hers my current script:

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function() player.PlayerGui.gameshop.Frame.Visible = true end)

1 comment

0

Is the shop being visible right now once you click?

2 answers

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

If script.Parent.Visible is true, which translating "not script.Parent.Visible" becomes to "not true" is false, it will set the visible status to false

But if the script.Parent.Visible is false, which translating "not script.Parent.Visible" becomes to "not false" is true, hence setting the visible status to true

Alright, so. I'll assume that the frame is named "Frame."

Put this as local script inside the button.

local open = false -- Don't touch this
local frame = script.Parent.Parent.Frame
script.Parent.MouseButton1Click:Connect(function()
if not open then -- If it is closed
frame.Visible = true
else
frame.Visible = false
end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.