I'd like to point out a few things here.
Firstly, is that the server can't be accessing children of the player's PlayerGui it did not parent, and should not be accessing it at all. You should fire a RemoteEvent to the client and have them do GUI actions client-side.
Secondly, we should use the player's user ID, instead of the player's name, because the player's user ID is a unique identifier that will never chnage.
Thirdly, we can use a dictionary lookup.
local Admins = {
[1] = "ROBLOX",
[537472621] = "Avigant"
}
game.Players.PlayerAdded:Connect(function(Player)
if not Admins[Player.UserId] then
return
end
end)
The keys are players' user IDs, and the values are player's usernames. When we look up Admins[Player.UserId] we get a string (their username) if it is in the table, or nil otherwise.
We use a player's username as the value in the table as an easy way to see who is who when we're editing our script, as it's more useful than true or another truthey value.
Though it probably won't matter in this case, it's worth pointing out that dictionary lookup is much faster than linear search (looping through an array, looking for a matching value) as the table grows. To simplify, dictionary lookup will only ever take one step, while linear search will take an additional step for every player you add to the table.
As a final note, RBXScriptSignal:connect() is deprecated, meaning you shouldn't use it, try RBXScriptSignal:Connect() instead.
3 comments
niceee
You can use a RemoteEvent just how I mentioned in the first part of my post.