Hello, I’m a beginner Lua scripter and I’m wondering why my script won’t work. I would like to make a script that bans somebody permanently and the only way to remove the ban is by removing the username on the script. Even with Adonis, I want it where the person is banned on the script, even if they are unbanned. Hopefully that makes sense. By the way, I have it in ServerScriptStorage.
Here’s the script:
game.Players.PlayersAdded:Connect(function(player)
if player.Named == {"Fuserna"} or {"FNTDREAMSreborn"} then
player:Kick("Sorry")
end
end)
This is just for testing, and I would like if somebody can revamp it so it can work!
game.Players.PlayersAdded:Connect(function(player)
if player.Name == "Fuserna" or player.Name = "FNTDREAMSreborn" then
player:Kick("Sorry")
end
end)
By the way, using UserIds is better in case the player changes their username. You could do something like this instead:
game.Players.PlayersAdded:Connect(function(player)
if player.UserId == ThePlayersUserId or player.UserId == TheOtherPlayersUserId then
player:Kick("Sorry")
end
end)
This is a more organized way to do it:
local BannedPlayers = {
--Put their userids in a table
}
game.Players.PlayerAdded:Connect(function(player)
if table.find(player.UserId, BannedPlayers) then
player:Kick("Sorry")
end
end)
Like if you said "/sg Gun} - It’s basically like a specific word(s) to spawn a gun (with limited spawns of course) - (with your name added on the script, it wouldve work), idk I just saw that in some script.
And I don’t know about the “Named” thing, I think I probably misspelled it or did something wrong with it.
--game.Players.PlayersAdded:Connect(function(player)
-- if player.Name == "Fuserna" or player.Name == "FNTDREAMSreborn" then
-- player:Kick("Sorry")
--end
--end)
local BannedPlayers = {
"675726563" --Put their userids in a table
}
game.Players.PlayersAdded:Connect(function(player)
if table.find(player.UserId, BannedPlayers) then
player:Kick("Sorry")
end
end)
local BannedPlayers = {
675726563 --Put their userids in a table
}
game.Players.PlayersAdded:Connect(function(player)
if table.find(BannedPlayers, player.UserId) then
player:Kick("Sorry")
end
end)
Make sure it is game.Players.PlayerAdded and not game.Players.PlayersAdded. I noticed that while I was testing it in my own game. It worked after I changed that.
the script without the error
local BannedPlayers = {
675726563
}
game.Players.PlayerAdded:Connect(function(player)
if table.find(BannedPlayers, player.UserId) then
player:Kick("Sorry")
end
end)