local Moderators = {"Sk3pticalR0BL0X"} --Enter the names of players who can use the GUI.
----------------------------------
-- DO NOT EDIT BEYOND THIS LINE --
----------------------------------
game.Players.PlayerAdded:connect(function(GetMods)
game.Lighting.KickGUI:Clone().Parent = game.Players[Moderators].PlayerGui
end)
Script not cloning GUI into PlayerGUI for Allowed players, anyone know how I can fix this??
1 answer
For first, :connect is deprecated. Use :Connect
You need to use a "For loop", for get moderator use generic for loop. example:
-- Generic for loop
-- Basically generic for loop have "index,value" the value is the string stored in a table, and index is "string position", example:
local Table = {"String1","String2","String3"}
-- also you can use: i,v
for index,value in pairs(Table) do
print("The index is: " .. tostring(index) .. " The value is: " .. tostring(value))
end
local moderators = {"Player1","Player2","Player3"}
game.Players.PlayerAdded:Connect(function(Player)
-- if you use _,... or ...,_ the _ is a nil value, after you put _ you can't use this.
for _,moderator in pairs(moderators) do -- Generic for loop, getting all strings in table
-- if you use print(_) this return nil.
if Player.Name == moderator then -- Check if Player Name is equal to moderator name
print("The player: " .. Player.Name .. " is a moderator!")
end
end
end)
For your script you can use this:
local Moderators = {"Sk3pticalR0BL0X"} --Enter the names of players who can use the GUI.
----------------------------------
-- DO NOT EDIT BEYOND THIS LINE --
----------------------------------
game.Players.PlayerAdded:Connect(function(Player)
for _,moderator in pairs(Moderators) do
if Player.Name == moderator then
game.Lighting.KickGUI:Clone().Parent = Player:WaitForChild("PlayerGui")
-- Lighting is not a good way to storage items, use ServerStorage for this.
end
end
end)
Wiki pages:
Hope it helped
11 comments
my one did work.
I recommend that you include some kind of note that tells the OP to not use Lighting as storage.
use for loop is better
Also, it might be a good idea to have the admin UserId or name as the index so that you can simply check if they are an admin by doing if adminList[name] then or if adminList[UserId] then.
That is a lot more efficient than a for loop.
I don't think it would be necessary to add another check.
GUYS STOP DOWNVOTING WE GET IT
yHasteeD, it would not be adding another check, it would be removing the for loop altogether and replacing it with a more efficient method.
You can learn more about it in the second part of my answer, or in FredFishy's answer here: https://scriptinghelpers.org/questions/72402/how-do-i-remove-all-duplicates-of-a-array#68563
Not the same situation or problem, but the implementation of a hash table is what I am trying to get you to understand is more efficient than a for loop.
Why call tostring on what already is a string
This discussion is preserved as it was. New answers, comments, and votes are closed.

7 comments
i have fixed my answer
and checked it
that is not how a table works... use a loop
That isn't how an array works either.
free model, :connect() is in this along with those comments
W is it a free model?
i'm a little late (ok, maybe not a little), but no the comments are written for the other other devs.