Apologies, didn’t see the reply. Is the ID being provided correctly as a number? If not you could use tonumber() or tointeger() to convert it. You should also rename player to playerId or something similar to avoid confusion.
local FunctionTable = {
SPermBanTable = {
[23199234060] = {"Bye Megami"},
[2319923406] = {"Bye Megami"},
}
}
FunctionTable.SUNbanPlayer = function(UserId)
if FunctionTable.SPermBanTable[UserId] then
print(FunctionTable.SPermBanTable[UserId])
end
end
Incase it doesn’t that means that whatever data you are passing is wrong. Make sure the data you’re passing is actually valid (printing it and seeing what it is.)
Hello, I am passing the correct data, I just verified so by printing it. Here is my full script:
--Tables
local FunctionTable = {
SPermBanTable = {
[23199234060] = {"Bye Megami"},
[2319923406] = {"Bye Megami"}
}
}
--Function
function FunctionTable.SPermBanOnlinePlayer(Player, Reason)
table.insert(FunctionTable["SPermBanTable"], Player.UserId, {Reason})
Player:Kick("You have received a permanent server ban from this server. The reason is: "..Reason)
end
function FunctionTable.SPermBanOfflinePlayer(Player, Reason)
table.insert(FunctionTable["SPermBanTable"], Player, {Reason})
end
function FunctionTable.SUnbanPlayer(UserId)
FunctionTable.SUNbanPlayer = function(UserId)
if FunctionTable.SPermBanTable[UserId] then
print(FunctionTable.SPermBanTable[UserId])
end
end
end
--Return the functions
return FunctionTable
table.find searches for values (the ban reasons) within a table, not indexes (the userids). Change the code so that it’s indexing the table instead.
print(FunctionTable.SPermBanTable[Player]) -- Indexing with square brackets isn't really needed here
Above issue was fixed, but now you’re just declaring another function when you call FunctionTable.SUnbanPlayer() instead of actually executing the code to print.
Removing the declaration should finally have it working:
function FunctionTable.SUnbanPlayer(UserId)
local bannedPlayer = FunctionTable.SPermBanTable[UserId]
if bannedPlayer then
print(bannedPlayer )
end
end
Are you printing it on the server? Printing it on the client is no good.
You seem to have a huge misconception about how the “table” function table works and are using it when it’s not needed.
--Tables
local FunctionTable = {
SPermBanTable = {
[23199234060] = {"Bye Megami"},
[2319923406] = {"Bye Megami"}
}
}
--Function
function FunctionTable.SPermBanOnlinePlayer(Player, Reason)
FunctionTable.SPermBanTable[Player] = {Reason}
Player:Kick("You have received a permanent server ban from this server. The reason is: "..Reason)
end
function FunctionTable.SPermBanOfflinePlayer(Player, Reason)
FunctionTable.SPermBanTable[Player] = {Reason}
end
function FunctionTable.SUnbanPlayer(UserId)
FunctionTable.SUNbanPlayer = function(UserId)
if FunctionTable.SPermBanTable[UserId] then
print(FunctionTable.SPermBanTable[UserId])
end
end
end
--Return the functions
return FunctionTable
The code above should work, if there are still issues please post a photo of your output logs in order for me to properly identify what the issue in the code is.