So, I have a script that is meant to function when a Player is added. Once fired, it checks if that player's name equals one of the values inside of a folder inside of the script. If it matches, it then kicks the player and displays a custom message, but it doesn't function, and I can't find out why.
local WhiteList = script.Folder:GetChildren() local Defined = script.Folder.Defined.Value local Player = game.Players.PlayerAdded local A = script.Folder("1").Value local B = script.Folder("2").Value local C = script.Folder("3").Value local D = script.Folder("4").Value local E = script.Folder("5").Value game.Players.PlayerAdded:connect(function() if Player == Defined then game.Players(Player):Kick("Go away, you have no friends...") print("Player Attempted to join!") elseif Player.Name == A or B or C or D or E then game.Players(Player):Kick("Bai!") end end)
For help, here is the model: http://www.roblox.com/THIS-IS-SPARTA-item?id=339927939
Now, I am going to completely redesign your script, the first being an improvement of your one, and the second being a new (but much more efficient) way to do it.
Redesign #1:
local whitelist = script.Folder:GetChildren() function WhiteListCheck(p) for _,v in pairs (whitelist) do if v.Value == p.Name then return true end end end game.Players.PlayerAdded:connect(function(p) local banned = WhiteListCheck(p) if banned == true then p:Kick("You are banned from this game") end end)
This code cycles through all of the the children of whitelist, checking to see if their value is the Player's name. If it is, it returns true, and the PlayerAdded function kicks them.
Redesign #2
local whitelist = { ["PlayerName"] = true, ["PlayerName"] = true } game.Players.PlayerAdded:connect(function(p) if whitelist[p.Name] then p:Kick("You are banned from this game") end end)
This code just checks to see if the player is in the table, and if they are, they get kicked.
local WhiteList = script.Folder:GetChildren() local Defined = script.Folder.Defined.Value local Player = game.Players.PlayerAdded local A = script.Folder("1").Value local B = script.Folder("2").Value local C = script.Folder("3").Value local D = script.Folder("4").Value local E = script.Folder("5").Value game.Players.PlayerAdded:connect(function() if Player.Name == Defined then -- Try Player.Name game.Players(Player):Kick("Go away, you have no friends...") -- lol print("Player Attempted to join!") elseif Player.Name == A or B or C or D or E then game.Players(Player):Kick("Bai!") end end)
Now i may be totally wrong because im tired asf but, Try it . . .