Hey there,
So I am working on an admin panel for my game. Below is the whole server script for the panel. Everything works fine, but the “Unban” action is not working. I am getting the “Event Fired2” message in the output telling me that it is getting to that point of the script, but not removing the player from the datastore.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DatastoreService = game:GetService("DataStoreService")
local EventsFolder = ReplicatedStorage.StaffPanelEvents
local ActionEvent = EventsFolder.AdminActions
local GetBanListEvent = EventsFolder.GetBanList
local BanDS = DatastoreService:GetDataStore("FullBanList")
local key = "BanList"
ActionEvent.OnServerEvent:Connect(function(adminplr,action,playername,content,content2)
local plrid = nil
local plr = nil
print("Event fired1")
if playername == nil then
else
plrid = game.Players:GetUserIdFromNameAsync(playername)
plr = game.Players:GetPlayerByUserId(plrid)
end
if action == "Kick" then
plr:Kick("You have been kicked by the staff member ".. adminplr.Name ..".")
end
if action == "TP" then
adminplr.Character.HumanoidRootPart.CFrame = plr.Character.HumanoidRootPart.CFrame + Vector3.new(0,2,1)
end
if action == "Bring" then
plr.Character.HumanoidRootPart.CFrame = adminplr.Character.HumanoidRootPart.CFrame + Vector3.new(0,2,1)
end
if action == "Kill" then
plr.Character.Humanoid.Health = 0
end
if action == "Unban" then
print("Event fired2")
BanDS:UpdateAsync(key, function(old)
old=old or {}
print("Event fired")
table.remove(old,plrid)
return old
end)
end
if action == "Message" then
local m = Instance.new("Hint",game.Workspace)
m.Name = "AdminMessage"
m.Text = content
if tonumber(content2) then
wait(tonumber(content2))
m:Destroy()
else
wait(3)
m:Destroy()
end
end
if action == "Ban" then
BanDS:UpdateAsync(key, function(old)
old=old or {}
old[plr.UserId]=true
return old
end)
plr:Kick("You are banned from this experience. You may appeal this action by contacting a staff member via our Discord.")
local data = BanDS:GetAsync(key)
local banlist = {}
for i,v in pairs(data) do
local playerName = game.Players:GetNameFromUserIdAsync(i)
print(playerName)
table.insert(banlist,playerName)
end
GetBanListEvent:FireAllClients(banlist)
end
end)
game.Players.PlayerAdded:Connect(function(plr)
local data = BanDS:GetAsync(key)
local banlist = {}
for i,v in pairs(data) do
local playerName = game.Players:GetNameFromUserIdAsync(i)
print(playerName)
table.insert(banlist,playerName)
if playerName == plr.Name then
plr:Kick("You are banned from this experience. You may appeal this action by contacting a staff member via our Discord.")
end
end
GetBanListEvent:FireAllClients(banlist)
end)
Any help would be greatly appreciated!
Thank you,