Hello, I’ve had an issue with my ban module in my command system.
DataStore Issue:
It does not save any bans that are made using the GUI.
Screenshots/Code:
Video
Admin Module
--Ban Player--
local function ban(player, value)
local players = game:GetService('Players')
local sus,erro = pcall(function()
local Id = players:GetUserIdFromNameAsync(player)
end)
if sus then
local Id = players:GetUserIdFromNameAsync(player)
local msg = tostring(player)..' has been banned'
ds:SetAsync(Id, {true, value})
for i,plr in pairs(game.Players:GetChildren()) do
if plr.Name == player.Name then
plr:kick("\n ⛔️ | You have been permanently banned. \n \n Reason: " .. value)
end
end
local color = Color3.fromRGB(255, 56, 88)
game.ReplicatedStorage.ChatMsg:FireAllClients(msg, color)
print(tostring(player).." has been banned")
end
end
--Unban Player
local function unban(player)
local players = game:GetService("Players")
local sus,erro = pcall(function()
local Id = players:GetUserIdFromNameAsync(player)
end)
if sus then
local Id = players:GetUserIdFromNameAsync(player)
ds:RemoveAsync(Id)
print(tostring(player).." has been unbanned")
end
end
Loader Module
local ds = game:GetService("DataStoreService"):GetDataStore("BanDataTest106")
game.Players.PlayerAdded:Connect(function(plr)
local data = ds:GetAsync(plr.UserId)
if data then
if data[1] == true then
plr:Kick("\n ⛔️ | You have been permanently banned. \n \n Reason: " .. data[2])
end
end
end)
Solutions I’ve tried:
Messing around with the code.
Looking on the dev forum.