Currently i am working on CodePrime8’s admin panel
But i have a problem with it. I keep getting this error:
ServerScriptService.Admin:38: attempt to concatenate string with nil
in this code:
-- Admin panel script
local AdminRE = game:GetService("ReplicatedStorage").AdminRE
local Admins = {}
local Bans = {}
local DSS = game:GetService("DataStoreService")
local AdminData = DSS:GetDataStore("Admins")
local BanData = DSS:GetDataStore("Ban")
local function CheckAdmin(player)
if player.Name == AdminData:GetAsync(player.UserId) then
print("Is Admin")
return true
else
print("Is Not An Admin")
return false
end
end
local function CheckBan(player)
local BandID = player.UserId
local BanReason = nil
local success, err = pcall(function()
BanReason = BanData:GetAsync(BandID)
end)
if success then
if BanReason == "none" then
-- leave empty
else
player:Kick("You are banned." .. player.Name .. "\n Reason: "..BanReason)
end
else
error("Could not check ban for "..player.Name .. ":" .. player.UserId .. " - " .. err)
end
end
local function AdminCmd(Admin, cmd, Target, Reason)
local Target = game.Players:FindFirstChild(Target)
if CheckAdmin(Admin) then
if cmd == "Kick" then
print("You just send the Kick command to the server")
Target:Kick("You have been kicked by an Admin")
end
if cmd == "Ban" then
BanData:SetAsync(Target.UserId, "You have been banned by " .. Admin.Name)
Target:Kick(Target.UserId, "You have been banned by " .. Admin.Name)
end
if cmd == "Freeze" then
print("Freezing " .. Target.Name)
game.Workspace:FindFirstChild(Target.Name).Head.Anchored = true
end
if cmd == "Unfreeze" then
print("Unfreezing " .. Target.Name)
game.Workspace:FindFirstChild(Target.Name).Head.Anchored = false
end
else
BanData:SetAsync(Admin.UserId, "Attempted to invoke the Admin Remote Event")
Admin:Kick("Kicked for attempting Admin Commands")
end
end
game.Players.PlayerAdded:Connect(CheckBan)
game.Players.PlayerAdded:Connect(CheckAdmin)
AdminRE.OnServerEvent:Connect(AdminCmd)
but the problem is on this line:
player:Kick("You are banned." .. player.Name .. "\n Reason: "..BanReason)
Can anybody help me.