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

Hide multiple frames at once?

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)

2 answers

✓ Accepted answer

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

1 comment

0

An easier solution would be to (if he/she wants to hide everything from the Gui) just disable/enable it. When it's something like If not Y == "y" then HUD.Enabled = true, let me know if this seems like an easier solution

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.

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