game.Players.PlayerAdded:Connect(function(player) local bruh = {"iiConstable_Subwayx","Censored my friends name"} -- Thats not his actual name for i, v in pairs(bruh) do if player.Name == v then return nil else player:Kick('This game is currently only open to ' .. bruh[1] .. ' and, ' .. bruh[2] .. '. This is still a work in progress') end end end)
Alright, if I try this, it only works for the name in table[1], For example, if I put my friend's name there and my name after, it's broken for me and kicks me, however, it would work for him, any ideas on why and how I could fix it?
well, your game kicks anyone in the table who's name matches one of the names in the array..
do this:
local bruh = {}; game.Players.PlayerAdded:Connect(function(player) for _, name in pairs(bruh) do if(name:lower() == player.Name:lower()) then return end end player:Kick("Your not allowed in") end)
Your problem is that you're checking the player's names, if it is in that table you defined, you want it to do nothing, why are you using return
? Return stops
that part from going on further
.
To clarify what I want to say here is how return works in your case, once it finds one
player that meets the condition it would stop
, and won't
check further
So what I suggest you do is
if player.Name ~= v then player:Kick('This game is currently only open to ' .. bruh[1] .. ' and, ' .. bruh[2] .. '. This is still a work in progress') end
Instead of what you already have, and it should go through all players in the table
Hope I helped, if you have further questions please let me know
Try replacing the [1] and [2] with i instead.
bruh[i]
Do this so the loop runs EVERYTHING avaliable in the table. You'll have to eventually add more text to your message if you want to add more people to your whitelist though.