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

local script does not make a screen guis children become invisible?

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

4 answers

✓ Accepted answer

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.

2 comments

0

@OP, sorry my mistake please follow what this guy corrected above. :)

0

i gave u the answer because i noticed your reputation was low

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)

2 comments

0

does not work either

0

sorry

: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)

4 comments

0

does not work

0

sorry

0

WeBuiltOurOwnWorld corrected my code mistake, instead of GiveDieChildren.v.Visible = false

0

Remove "GiveDieChildre" and just do this: v.Visible = false

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)

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