Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

shop open close button help?

Asked by 2 years ago

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)

0
Is the shop being visible right now once you click? Soban06 410 — 2y

2 answers

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago
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

Ad
Log in to vote
0
Answered by 2 years ago

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

Answer this question