The reason this script breaks is because when you run your for loop, if ANY player is not in the table, you get kicked. This being said, you have both yourself and "id" in your table, so you don't get kicked after the first loop, but because your name isn't "id" as well, you get kicked on the second one. There is a simple fix to this, just make another variable that defines whether the player should be kicked after the loop runs. Example:
local Devs = {"Player1", "Jxyzxrr"}
local Players = game:GetService("Players")
local kickPlayer = true
Players.PlayerAdded:Connect(function(player)
for i = 1, #Devs do
if player.Name == Devs[i] then
kickPlayer = false
end
end
if kickPlayer == true then
player:Kick("Not a developer: Dev access only.")
end
end)
Hope this helps!
8 comments
Please put in Block Code
Also what is it about, a Dev access door?
i am really getting pissed when people say "Please put in Block Code" when you cant paste it in block code, and it obviously is a script that kicks a player if they are not a developer. Jesus christ, no offense but are you a scripter at all? Did you look at the script?
is this a server or localscript?
is the problem that it doesn't do anything or that it kicks you even though you're a developer?
it kicks me, but im a dev
Yes, that's becaucause if you're not the first name in the "devs" table, the for loop will keep you. You now gave it the instructions to immediately kick somebody if their name doesn't mate up with the first string in the devs table, so that's where your problem is.
@Jxyzxrr You can actually paste your code in Block Code, just use the Block Code button at the top of the editor, it looks like "<>"