local GiveDieChildren = game.StarterGui.GiveDie:GetChildren() game.StarterGui.GiveDie.later.MouseButton1Click:Connect(function() script.Parent.Parent.GiveDieChildren.Visible = false end)
The local script is inside a text button inside the screen gui which when the text button is pressed it makes all the screen guis children become invisible
Yozoh had it semi correct, only thing he messed up on is doing GiveDieChildren.v.Visible
it should just be v.Visible
the for i, v in pairs() do
function gives you two values, i and v
i: index
v: value
. The index is the position of the value relative to the list given in the () and the value is whatever was found in the loop so in this case all of the children of GiveDie.
PS: i and v arent required names, you can name them whatever you want.
PlayerGui PlayerGui is the players StarterGui basically
local GiveDieChildren = game.Players.LocalPlayer.PlayerGui.GiveDie:GetChildren() game.Players.LocalPlayer.PlayerGui.GiveDie.later.MouseButton1Click:Connect(function() script.Parent.Parent.GiveDieChildren.Visible = false end)
:GetChildren() returns a table of the children, so you will need to loop through GiveDieChildren and turn the visibility false
local GiveDieChildren = game.StarterGui.GiveDie:GetChildren() game.StarterGui.GiveDie.later.MouseButton1Click:Connect(function() for i, v in pairs (GiveDieChildren) do GiveDieChildren.v.Visible = false end end)
I like to mix good things with other good things, I used that philosophy with all your scripts and closed the case! Here is the script that works.
local GiveDieChildren = game.Players.LocalPlayer.PlayerGui.GiveDie:GetChildren() game.Players.LocalPlayer.PlayerGui.GiveDie.later.MouseButton1Click:Connect(function() for i, v in pairs (GiveDieChildren) do v.Visible = false end end)