local banned = {'danyopera','mainmodul'}
game.Players.PlayerAdded:connect(function(player) if player == banned then game.Players.LocalPlayer:kick'Banned!' end end)
Banned is a table, so you can't say if the player is equal to a table. Since there's no lua function for checking if an item is in a list, you can just loop over the list and see if the player matches any of the entries.
local banned = {'danyopera','mainmodul'} game.Players.PlayerAdded:Connect(function(players) for i, name in pairs(banned) do if player.Name == name then player:kick("Banned!") end end end)
You're using a dictionary here, which isn't ideal, but it could allow for the following code to work:
local banned = {'danyopera','mainmodul'} game.Players.PlayerAdded:Connect(function(players) if banned[player.Name] then player:kick("Banned!") end end)
I'm not sure if it's player.Name or just player, but if you experiment a bit it should work.
You can use table.find()
to check if the player's name is in the table, it'll return nil if it cannot find the value specified inside the table, or it'll return the index position of that value.
local banned = {'danyopera','mainmodul'} game.Players.PlayerAdded:Connect(function(Player) if table.find(banned, Player.Name) then Player:Kick('Banned!') end end)
If you're going to implement a ban system in your game I wouldn't recommend using the players' name though, I'd recommend using their UserId which is a unique ID every account has upon creating their account. If a player changes their account name, their name won't be the same as the name inside the table anymore so they will be able to join. Their UserId cannot be changed in any way so it's recommended to use their UserId instead.