local SSS = game:GetService("ServerScriptService")
local MyModule = require(SSS:FindFirstChild("AdminSystemConfig").ModuleScript)
local DSS = game:GetService("DataStoreService"):GetDataStore("AdminPanel")
local Pban = {
}
-- Serverban Code
game.ReplicatedStorage["Admin System"].Pban.OnServerEvent:Connect(function(Player, plrToBan, Reason)
if Player:GetRankInGroup(MyModule.GroupID) >= MyModule.BanID then
if game.Players:FindFirstChild(plrToBan) then
DSS:SetAsync(plrToBan.UserId.."-BAN", plrToBan.UserId)
game:GetService("Players"):FindFirstChild(plrToBan):Kick("PERMBAN | ".. Reason)
Player.PlayerGui["Admin Panel"]:Destroy()
else
game.Players:WaitForChild(plrToBan)
DSS:SetAsync(plrToBan.UserId.."-BAN", plrToBan.UserId)
game:GetService("Players"):FindFirstChild(plrToBan):Kick("PERMBAN | ".. Reason)
Player.PlayerGui["Admin Panel"]:Destroy()
end
end
end)
-- Unban Code
--game.ReplicatedStorage["Admin System"].UnPermBan.OnServerEvent:Connect(function(Player, plrToUnban)
-- if Player:GetRankInGroup(MyModule.GroupID) > MyModule.UnbanID then
--local userID = game.Players:GetUserIdFromNameAsync(plrToUnban)
-- local index = table.find(Pban, userID)
-- table.remove(Pban, index)
-- Player.PlayerGui["Admin Panel"]:Destroy()
-- else
-- Player:Kick("Anti Exploit Protocol")
-- end
--end)
-- Serverban Handler
game.Players.PlayerAdded:Connect(function(plr)
if DSS:GetAsync(plr.UserId.."-BAN") then
plr:Kick("GAMEBAN | Je bent Permanent Verbannen van deze server, dit betekend dat je geen toegang meer hebt tot de game, klopt dit niet maak een ticket in de Community Server.")
end
end)
local SSS = game:GetService("ServerScriptService")
local MyModule = require(SSS:FindFirstChild("AdminSystemConfig").ModuleScript)
local DSS = game:GetService("DataStoreService"):GetDataStore("AdminPanel")
local Pban = {
}
-- Serverban Code
game.ReplicatedStorage["Admin System"].Pban.OnServerEvent:Connect(function(Player, plrToBan, Reason)
if Player:GetRankInGroup(MyModule.GroupID) >= MyModule.BanID then
if game.Players:FindFirstChild(plrToBan) then
DSS:SetAsync(game.Players[plrToBan].UserId)
game:GetService("Players"):FindFirstChild(plrToBan):Kick("PERMBAN | ".. Reason)
Player.PlayerGui["Admin Panel"]:Destroy()
else
game.Players:WaitForChild(plrToBan)
DSS:SetAsync(game.Players[plrToBan].UserId)
game:GetService("Players"):FindFirstChild(plrToBan):Kick("PERMBAN | ".. Reason)
Player.PlayerGui["Admin Panel"]:Destroy()
end
end
end)
-- Unban Code
--game.ReplicatedStorage["Admin System"].UnPermBan.OnServerEvent:Connect(function(Player, plrToUnban)
-- if Player:GetRankInGroup(MyModule.GroupID) > MyModule.UnbanID then
--local userID = game.Players:GetUserIdFromNameAsync(plrToUnban)
-- local index = table.find(Pban, userID)
-- table.remove(Pban, index)
-- Player.PlayerGui["Admin Panel"]:Destroy()
-- else
-- Player:Kick("Anti Exploit Protocol")
-- end
--end)
-- Serverban Handler
game.Players.PlayerAdded:Connect(function(plr)
if DSS:GetAsync(plr.UserId.."-BAN") then
plr:Kick("GAMEBAN | Je bent Permanent Verbannen van deze server, dit betekend dat je geen toegang meer hebt tot de game, klopt dit niet maak een ticket in de Community Server.")
end
end)
Oh yeah i just noticed that you removed .."-BAN", plrToBan.UserId in the SetAsync function.
Heres the fixed script:
local SSS = game:GetService("ServerScriptService")
local MyModule = require(SSS:FindFirstChild("AdminSystemConfig").ModuleScript)
local DSS = game:GetService("DataStoreService"):GetDataStore("AdminPanel")
local Pban = {
}
-- Serverban Code
game.ReplicatedStorage["Admin System"].Pban.OnServerEvent:Connect(function(Player, plrToBan, Reason)
if Player:GetRankInGroup(MyModule.GroupID) >= MyModule.BanID then
if game.Players:FindFirstChild(plrToBan) then
DSS:SetAsync(tostring(game.Players[plrToBan].UserId).."-BAN", game.Players[plrToBan].UserId)
game:GetService("Players"):FindFirstChild(plrToBan):Kick("PERMBAN | ".. Reason)
Player.PlayerGui["Admin Panel"]:Destroy()
else
game.Players:WaitForChild(plrToBan)
DSS:SetAsync(tostring(game.Players[plrToBan].UserId).."-BAN", game.Players[plrToBan].UserId)
game:GetService("Players"):FindFirstChild(plrToBan):Kick("PERMBAN | ".. Reason)
Player.PlayerGui["Admin Panel"]:Destroy()
end
end
end)
-- Unban Code
--game.ReplicatedStorage["Admin System"].UnPermBan.OnServerEvent:Connect(function(Player, plrToUnban)
-- if Player:GetRankInGroup(MyModule.GroupID) > MyModule.UnbanID then
--local userID = game.Players:GetUserIdFromNameAsync(plrToUnban)
-- local index = table.find(Pban, userID)
-- table.remove(Pban, index)
-- Player.PlayerGui["Admin Panel"]:Destroy()
-- else
-- Player:Kick("Anti Exploit Protocol")
-- end
--end)
-- Serverban Handler
game.Players.PlayerAdded:Connect(function(plr)
if DSS:GetAsync(tostring(plr.UserId).."-BAN") then
plr:Kick("GAMEBAN | Je bent Permanent Verbannen van deze server, dit betekend dat je geen toegang meer hebt tot de game, klopt dit niet maak een ticket in de Community Server.")
end
end)
(i also added tostring() in the SetAsync function because it would probably error if you would try to combine a UserId and string)
The error message suggests that the “Reason” variable might be nil. To fix this error, you can add a check to ensure that the “Reason” variable is not nil before concatenating it with the string. You can do this by modifying the line as follows:
game:GetService("Players"):FindFirstChild(plrToBan):Kick("PERMBAN | ".. (Reason or ""))
This will ensure that if the “Reason” variable is nil, it will default to an empty string and the concatenation will not result in an error.
@Xacima The ban check doesn’t work, it bans me now if i fire the script, but if i rejoin i can simply join the game without kick.
Check Script:
game.Players.PlayerAdded:Connect(function(plr)
if DSS:GetAsync(tostring(plr.UserId.."-BAN")) then
plr:Kick("GAMEBAN | Je bent Permanent Verbannen van deze server, dit betekend dat je geen toegang meer hebt tot de game, klopt dit niet maak een ticket in de Community Server.")
end
end)
Here’s an updated version of how you can use the GetAsync function properly, this should also solve the issue that you’re having.
local Ok, Result = pcall(function()
return DSS:GetAsync(tostring(plr.UserId.."-BAN"))
end)
if (Ok) then
-- // If the call was successful
if (Result) then
plr:Kick("GAMEBAN | Je bent Permanent Verbannen van deze server, dit betekend dat je geen toegang meer hebt tot de game, klopt dit niet maak een ticket in de Community Server.")
-- If the player has any data, kick them
else
-- // Player does not have any data
end
else
-- // Unable to get the player's data
end