Is there a way to set the visible of multiple frames to falsest at once? something like:
--// Variables local HUD = script.Parent.Parent.HUD local plr = game.Players.LocalPlayer --// Show/Hide HUD plr:GetMouse () .KeyDown:Connect(function(Y) if Y == "y" then HUD:GetChildren().Visible = false end end)
Hello, loganmatt3!
That can be easily solved using a For Loop, more specifically, using it to iterate throught the array that is returned by :GetChildren()
.
More information about it can be found on:
https://education.roblox.com/en-us/resources/pairs-and-ipairs-intro
https://developer.roblox.com/en-us/articles/Loops
I also noticied you are using Mouse
to detect when a key is pressed, you should be using UserInputService
to detect it, as Mouse.KeyDown
was deprecated some years ago.
More information can be found here:
https://developer.roblox.com/en-us/api-reference/class/UserInputService
https://developer.roblox.com/en-us/api-reference/class/Mouse
If this answer helps you, please mark it as "accepted"
Good luck with your games
If you want to disable all of the frames in a Gui, do this:
local player = game.Players.LocalPlayer -- get player local GUI = player.PlayerGui.YourGuiHere -- Get the Player's Gui (Change it to what you have) player:GetMouse () .KeyDown:Connect(function(Y) if Y == "y" then GUI.Enabled = false end end)
If there's anything wrong let me know.