Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago
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

Log in to vote
0
Answered by 3 years ago

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.

0
@OP, sorry my mistake please follow what this guy corrected above. :) Yozoh 146 — 3y
0
i gave u the answer because i noticed your reputation was low Jakob_Cashy 79 — 3y
Ad
Log in to vote
0
Answered by
iuclds 720 Moderation Voter
3 years ago

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)
0
does not work either Jakob_Cashy 79 — 3y
0
sorry Jakob_Cashy 79 — 3y
Log in to vote
0
Answered by
Yozoh 146
3 years ago
Edited 3 years ago

: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)
0
does not work Jakob_Cashy 79 — 3y
0
sorry Jakob_Cashy 79 — 3y
0
WeBuiltOurOwnWorld corrected my code mistake, instead of GiveDieChildren.v.Visible = false Yozoh 146 — 3y
0
Remove "GiveDieChildre" and just do this: v.Visible = false Yozoh 146 — 3y
Log in to vote
0
Answered by 3 years ago

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)

Answer this question