Hello! I am making a toggle button that toggles all the gui’s. Problem is; none of them won’t be visible. On top of that, no errors print in console.
Code:
local Main = script.Parent.Parent
local visible = false
for i,v in ipairs(require(Main:WaitForChild("Whitelist")).wl) do
if game.Players.LocalPlayer.UserId == v then
if visible == false then
visible = true
for _, u in pairs(Main:GetDescendants()) do
if (not u.ClassName == "Folder" or not u.ClassName == "ModuleScript" or not u.ClassName == "LocalScript" or not u.ClassName == "Script" and u.Name ~= "Tog") then
u.uisible = true
end
end
else
visible = false
for _, u in pairs(Main:GetDescendants()) do
if (not u.ClassName == "Folder" or not u.ClassName == "ModuleScript" or not u.ClassName == "LocalScript" or not u.ClassName == "Script" and u.Name ~= "Tog") then
u.uisible = false
end
end
end
end
end
Fixed that; should’ve worked. But it doesn’t… No errors in the console still.
New Code:
local Main = script.Parent.Parent
local visible = false
for i,v in ipairs(require(Main:WaitForChild("Whitelist")).wl) do
if game.Players.LocalPlayer.UserId == v then
if visible == false then
visible = true
for _, u in pairs(Main:GetDescendants()) do
if (not u.ClassName == "Folder" or not u.ClassName == "ModuleScript" or not u.ClassName == "LocalScript" or not u.ClassName == "Script" and u.Name ~= "Tog") then
u.Visible = true
end
end
else
visible = false
for _, u in pairs(Main:GetDescendants()) do
if (not u.ClassName == "Folder" or not u.ClassName == "ModuleScript" or not u.ClassName == "LocalScript" or not u.ClassName == "Script" and u.Name ~= "Tog") then
u.Visible = false
end
end
end
end
end
The ScreenGUI is usually disabled by default. The whitelist system goes through and detects if the player is whitelisted, if so, it enables the ScreenGUI. Which in this scenario, it did. I see the toggle button.
I have attempted to rewrite the for loops, still doesn’t work. Here is the new code;
local Main = script.Parent.Parent
local visible = false
script.Parent.MouseButton1Click:Connect(function()
for i,v in ipairs(require(Main:WaitForChild("Whitelist")).wl) do
if game.Players.LocalPlayer.UserId == v then
if visible == false then
visible = true
for _, u in pairs(Main:GetDescendants()) do
if (u.ClassName == "Frame" or u.ClassName == "TextButton" or u.ClassName == "TextLabel" and u.Name ~= "Tog") then
u.Visible = true
end
end
else
visible = false
for _, u in pairs(Main:GetDescendants()) do
if (u.ClassName == "Frame" or u.ClassName == "TextButton" or u.ClassName == "TextLabel" and u.Name ~= "Tog") then
u.Visible = false
end
end
end
end
end)