Trying to make a Blacklisting system, is there an easier way to do this? I’m really new to programming, thanks.
local BlacklistedPlayers1 = {
1 --Builderman
}
local BanReason1 = "You have been banned indefinitely for the following reason: Exploiting"
--Exploit Ban Below
game.Players.PlayerAdded:Connect(function(player)
for i, v in pairs(BlacklistedPlayers1) do
if v == player.UserId then
player:Ban(BanReason1)
end
end
end)
local BlacklistedPlayers2 = {
2 --Example
}
local BanReason2 = "You have been banned indefinitely for the following reason: Hate Speech"
--Exploit Ban Below
game.Players.PlayerAdded:Connect(function(player)
for i, v in pairs(BlacklistedPlayers2) do
if v == player.UserId then
player:Ban(BanReason2)
end
end
end)
Well one way you can do this is by making it opposite of what you have the solution marked as so like this,
local BlacklistedPlayers = {
["Uh oh stinky cheerios"] = {
UserId1,
UserId2
}
}
game.Players.PlayerAdded:Connect(function(player)
for _, reason in ipairs(BlacklistedPlayers) do
if reason[player.UserId] then
player:Kick(reason)
end
end
end)
local BlacklistedPlayers = {
["Uh oh stinky cheerios"] = {
[UserId1] = true,
[UserId2] = true,
}
}
game.Players.PlayerAdded:Connect(function(player)
for KickReason, reason in pairs(BlacklistedPlayers) do
if reason[player.UserId] then
player:Kick(KickReason)
end
end
end)
.
How would I make it for separate the reasons, so sorry.
.
local BlacklistedPlayers = {
["You have been banned indefinitely for the following reason: EXPLOTING *THIS BAN IS NOT APPEABLE*"] = {
1, --Builderman
2 --Nullified0
}
["You have been banned indefinitely for the following reason: Hate Speech *THIS BAN IS NOT APPEABLE*"] = {
3, --Random
85387607 --Random
}
game.Players.PlayerAdded:Connect(function(player)
for _, reason in ipairs(BlacklistedPlayers) do
if reason[player.UserId] then
wait(1.5)
player:Kick(reason)
end
end
end)
local BlacklistedPlayers = {
["You have been banned indefinitely for the following reason: EXPLOTING *THIS BAN IS NOT APPEABLE*"] = {
1, --Builderman
2 --Nullified0
},
["You have been banned indefinitely for the following reason: Hate Speech *THIS BAN IS NOT APPEABLE*"] = {
3, --Random
85387607 --Random
}
}
game.Players.PlayerAdded:Connect(function(player)
for _, reason in ipairs(BlacklistedPlayers) do
if reason[player.UserId] then
wait(1.5)
player:Kick(reason)
end
end
end)
This should still work! Make sure to mark the proper solution for people that need it in the future!
Alright we’ll this can be fixed with some simple debugging
local BlacklistedPlayers = {
["You have been banned indefinitely for the following reason: EXPLOTING *THIS BAN IS NOT APPEABLE*"] = {
1, --Builderman
2 --Nullified0
},
["You have been banned indefinitely for the following reason: Hate Speech *THIS BAN IS NOT APPEABLE*"] = {
3, --Random
85387607 --Random
}
}
game.Players.PlayerAdded:Connect(function(player)
for reason, userIds in pairs(BlacklistedPlayers) do
print(reason, userIds)
if userIds[player.UserId] then
wait(1.5)
player:Kick(reason)
end
end
end)
14:30:55.866 Requiring asset 512742721.
Callstack:
cloud_144938633.archimedesTwo.initiatePlugin.MainModule, line 29
cloud_144938633.archimedesTwo.initiatePlugin.MainModule, line 28
- Server
14:30:55.967 Requiring asset 518094091.
Callstack:
cloud_144938633.archimedesTwo.initiatePlugin.MainModule, line 30
cloud_144938633.archimedesTwo.initiatePlugin.MainModule, line 28
- Server
If that is the only output try another debugging script:
local BlacklistedPlayers = {
["You have been banned indefinitely for the following reason: EXPLOTING *THIS BAN IS NOT APPEABLE*"] = {
1, --Builderman
2 --Nullified0
},
["You have been banned indefinitely for the following reason: Hate Speech *THIS BAN IS NOT APPEABLE*"] = {
3, --Random
85387607 --Random
}
}
game.Players.PlayerAdded:Connect(function(player)
print(BlacklistedPlayers)
for reason, userIds in pairs(BlacklistedPlayers) do
print(reason, userIds)
if userIds[player.UserId] then
wait(1.5)
player:Kick(reason)
end
end
end)