Hi, so I had this idea to create a Folder in Workspace called "Admins" and add BoolValue's inside. These BoolValue's would each be named after a person that is considered an Admin. These BoolValue's are manually added in studio, not via a running script.
Now, what I want to do is use a server-sided script to check if a user's name is found in that folder, and if so, he would (For example) receive a GUI. But, if their name isn't found in the list, nothing would happen.
I'm having issues with extracting the Children from this folder into my script, but this is what I've tried so far;
game.Players.PlayerAdded:connect(function(player) local folder = game.Workspace.Admins local name = player.Name if name == folder:GetChildren().Name then script.ScreenGui:Clone().Parent = name:WaitForChild("PlayerGui") end end)
The script waits till the user joins the game, then checks if your name is in the Folder as a BoolValue, and if so, your GUI appears on your screen.
I get no errors whatsoever, the GUI just simply does not appear on my screen, nor in my Player's PlayerGui.
NOTE: I added the GUI to the Player's PlayerGui because I have no clue where else to put it to ensure the player still has the GUI upon respawn. Haven't tried a CharacterAdded function yet, could this work? Thanks!
GetChildren returns a table of the children that you can iterate through to check if any child meets the requirements:
game.Players.PlayerAdded:Connect(function(player) local folder = game.Workspace.Admins local name = player.Name for _,v in pairs(folder:GetChildren()) do if v.Name == name then script.ScreenGui:Clone().Parent = player:WaitForChild("PlayerGui") break end end end)
However, it may just be more efficient to store the admin names in a table in the script. If you need to access the admin list from multiple scripts, you can use ModuleScripts. Also, you need to look inside the player for their PlayerGui, not their name.
GetChildren()
returns an array (table) so you would have to go through all the values of the table using pairs()
game.Players.PlayerAdded:Connect(function(player) local folder = game.Workspace.Admins for _,v in pairs(folder:GetChildren())do if player.Name == v.Name then script.ScreenGui:Clone().Parent = player:WaitForChild("PlayerGui") end end end)