Hello, how can I make sure that if I press the button all became → ‘true’ and if I press the same button again all became → ‘false’, can someone help me with that please!!
Example, press the button (dance 1,2,3,4,5,6 and 7 became true) and then if i press same button again all (1,2,3,4,5,6 and 7) became false, how i do that?
local open = script.Parent.Parent.Dance
local value = false
open.MouseButton1Click:Connect(function()
script.Parent["Dance 1"].Visible = not value
script.Parent["Dance 2"].Visible = not value
script.Parent["Dance 3"].Visible = not value
script.Parent["Dance 4"].Visible = not value
script.Parent["Dance 5"].Visible = not value
script.Parent["Dance 6"].Visible = not value
script.Parent["Dance 7"].Visible = not value
value = not value
end)
I only need to make a menu, that when I press ‘dance’ all the buttons are shown and when I press dance again all the buttons are closed and thus, having ‘dance’ always visible
By the way, you may want to use the MouseButton1Down event since, sometimes, MouseButton1Click does not work with mobile devices.
You could also shorten your code a bit using for loops.
local open = script.Parent.Parent.Dance
local isOpen = false
open.MouseButton1Down:Connect(function()
isOpen = not isOpen
for danceNumber = 1, 7 do
local danceObject = script.Parent:FindFirstChild("Dance " .. i)
if not danceObject then
continue
end
danceObject.Visible = isOpen
end
end)