How would i kick players every player joining the server/game without kick owner or some player

i need help to make kick system like kick every player joining the server or game without kick owner or some player like my friend or tester…

1 Like

Hm. Maybe try that:

local antiKick = {game.CreatorId, 1234, 4654, 8454} -- Fill in IDs.

game.Players.PlayerAdded:Connect(function(plr)
plr:Kick("Not an developer.")
elseif table.find(antiKick, plr.UserId) then
print("Developer!")
 end
end)
  1. There is a event called Players | Roblox Creator Documentation. Use it
game:GetService("Players").PlayerAdded:Connect(function(Player)

end)
  1. There is a function with players that you can kick them Player | Roblox Creator Documentation
Player:Kick()
  1. You can check whether or not a player is in the list by using the table.find function mentioned above table | Roblox Creator Documentation
1 Like

Fix to @achdef’s script:

local antiKick = {game.CreatorId, "KJry_s", 1234} -- Fill in UserIds or Player names

game:GetService("Players").PlayerAdded:Connect(function(newPlayer)
   if not table.find(antiKick, newPlayer.UserId) and not table.find(antiKick, newPlayer.Name) then
      newPlayer:Kick("Game access denied.")
   else
      -- Player has access
   end
end)

4 Likes

THere’s no need for a mixed table, userids is the best to go about it, no need to also have names in it, the ones with names in the table will no longer have access if they change their username and would require manual changing, whereas UserIds never change

local antiKick = {game.CreatorId, 6456, 647, 57}

game:GetService("Players").PlayerAdded:Connect(function(newPlayer)
   if not table.find(antiKick, newPlayer.UserId) then
      newPlayer:Kick("Game access denied.")
   else
      -- Player has access, do whatever here, if nothing special happens to
      -- Allowed users, just get rid of the else statement
   end
end)
3 Likes