and for some reason i don’t know what is causing it
here is the script
-- DataStore
local DataStoreService = game:GetService("DataStoreService")
local PlayerStore = DataStoreService:GetDataStore("PlayerData")
local getSuccess,bannedPlayers = pcall(function()
return PlayerStore:GetAsync("BannedPlayers")
end)
if not bannedPlayers then
local bannedPlayers = {}
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
end
---------------------------------------------------------------------------------------------------------------------------------
--- Ban command
local admins = {1593195522, 3505876378}
local prefix = "/"
local LocalChatMessage = game.ReplicatedStorage.LocalChatMessage
local function checkCommand(player, message)
message = string.lower(message)
local args = string.split(message, " ")
if args[1] == prefix.."ban" then
print(args[2])
local id
local success, response = pcall(function()
id = game.Players:GetUserIdFromNameAsync(args[2])
end)
if success then
table.insert(bannedPlayers,id)
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully banned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully banned "..args[2]..".", false)
end
for _,player in ipairs(game.Players:GetPlayers()) do
if player.Name:lower() == args[2] then
player:Kick("get dunked on")
break
end
end
elseif args[1] == prefix.."unban" then
local id
local success, response = pcall(function()
id = game.Players:GetUserIdFromNameAsync(args[2])
end)
if success then
table.remove(bannedPlayers, table.find(bannedPlayers, id))
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully unbanned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully unbanned "..args[2]..".", false)
end
end
end
local function checkPlayer(player)
if table.insert(bannedPlayers, player.UserId) then
player:Kick("You have been banned for")
return
end
if table.find(admins, player.UserId) then
player.Chatted:Connect(function(message)
checkCommand(player, message)
end)
end
end
game.Players.PlayerAdded:Connect(checkPlayer)
if table.insert(bannedPlayers, player.UserId) then
Instead of:
if table.find(bannedPlayers, player.UserId) then
New code:
-- DataStore
local DataStoreService = game:GetService("DataStoreService")
local PlayerStore = DataStoreService:GetDataStore("PlayerData")
local getSuccess,bannedPlayers = pcall(function()
return PlayerStore:GetAsync("BannedPlayers")
end)
if not bannedPlayers then
local bannedPlayers = {}
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
end
---------------------------------------------------------------------------------------------------------------------------------
--- Ban command
local admins = {1593195522, 3505876378}
local prefix = "/"
local LocalChatMessage = game.ReplicatedStorage.LocalChatMessage
local function checkCommand(player, message)
message = string.lower(message)
local args = string.split(message, " ")
if args[1] == prefix.."ban" then
print(args[2])
local id = nil
local success, response = pcall(function()
id = game.Players:GetUserIdFromNameAsync(args[2])
end)
if success then
table.insert(bannedPlayers,id)
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully banned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully banned "..args[2]..".", false)
end
for _,player in ipairs(game.Players:GetPlayers()) do
if player.Name:lower() == args[2] then
player:Kick("get dunked on")
break
end
end
elseif args[1] == prefix.."unban" then
local id
local success, response = pcall(function()
id = game.Players:GetUserIdFromNameAsync(args[2])
end)
if success then
table.remove(bannedPlayers, table.find(bannedPlayers, id))
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully unbanned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully unbanned "..args[2]..".", false)
end
end
end
local function checkPlayer(player)
if table.find(bannedPlayers, player.UserId) then
player:Kick("You have been banned for")
return
end
if table.find(admins, player.UserId) then
player.Chatted:Connect(function(message)
checkCommand(player, message)
end)
end
end
game.Players.PlayerAdded:Connect(checkPlayer)
hmm i tried it and still the same error file:///var/folders/gj/q3y96c7j45g0wp21c20jlptc0000gp/T/TemporaryItems/NSIRD_screencaptureui_fzXwv4/Screen%20Shot%202022-07-29%20at%2011.57.04%20AM.png
--//Services
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local PlayerStore = DataStoreService:GetDataStore("PlayerData")
local LocalChatMessage = ReplicatedStorage.LocalChatMessage
--//Controls
local admins = {1593195522, 3505876378}
local prefix = "/"
--//Initialization
local getSuccess, bannedPlayers = pcall(function()
return PlayerStore:GetAsync("BannedPlayers")
end)
if not getSuccess and not bannedPlayers then
bannedPlayers = {}
local setSuccess, errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
end
--//Functions
local function checkCommand(player, message)
message = string.lower(message)
local args = string.split(message, " ")
if args[1] == prefix.."ban" then
print(args[2])
local id = nil
local success, response = pcall(function()
id = Players:GetUserIdFromNameAsync(args[2])
end)
if id then
table.insert(bannedPlayers,id)
local setSuccess, errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully banned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully banned "..args[2]..".", false)
end
for i, player in ipairs(Players:GetPlayers()) do
if player.Name:lower() == args[2] then
player:Kick("get dunked on")
break
end
end
elseif args[1] == prefix.."unban" then
local id = nil
local success, response = pcall(function()
id = Players:GetUserIdFromNameAsync(args[2])
end)
if id then
table.remove(bannedPlayers, table.find(bannedPlayers, id))
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully unbanned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully unbanned "..args[2]..".", false)
end
end
end
local function checkPlayer(player)
if table.find(bannedPlayers, player.UserId) then
player:Kick("You have been banned for")
return
end
if table.find(admins, player.UserId) then
player.Chatted:Connect(function(message)
checkCommand(player, message)
end)
end
end
Players.PlayerAdded:Connect(function(player)
checkPlayer(player)
end)
--//Services
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local PlayerStore = DataStoreService:GetDataStore("PlayerData")
local LocalChatMessage = ReplicatedStorage.LocalChatMessage
--//Controls
local admins = {1593195522, 3505876378}
local prefix = "/"
local bannedPlayers = {}
--//Initialization
local getSuccess, errorMessage = pcall(function()
bannedPlayers = PlayerStore:GetAsync("BannedPlayers")
end)
--//Functions
local function checkCommand(player, message)
message = string.lower(message)
local args = string.split(message, " ")
if args[1] == prefix.."ban" then
print(args[2])
local id = nil
local success, response = pcall(function()
id = Players:GetUserIdFromNameAsync(args[2])
end)
if id then
table.insert(bannedPlayers,id)
local setSuccess, errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully banned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully banned "..args[2]..".", false)
end
for i, player in ipairs(Players:GetPlayers()) do
if player.Name:lower() == args[2] then
player:Kick("get dunked on")
break
end
end
elseif args[1] == prefix.."unban" then
local id = nil
local success, response = pcall(function()
id = Players:GetUserIdFromNameAsync(args[2])
end)
if id then
table.remove(bannedPlayers, table.find(bannedPlayers, id))
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully unbanned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully unbanned "..args[2]..".", false)
end
end
end
local function checkPlayer(player)
if table.find(bannedPlayers, player.UserId) then
player:Kick("You have been banned for")
return
end
if table.find(admins, player.UserId) then
player.Chatted:Connect(function(message)
checkCommand(player, message)
end)
end
end
Players.PlayerAdded:Connect(function(player)
checkPlayer(player)
end)
-- DataStore
local DataStoreService = game:GetService("DataStoreService")
local PlayerStore = DataStoreService:GetDataStore("PlayerData")
local getSuccess,bannedPlayers = pcall(function()
return PlayerStore:GetAsync("BannedPlayers")
end)
if not bannedPlayers then
bannedPlayers = {}
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
end
---------------------------------------------------------------------------------------------------------------------------------
--- Ban command
local admins = {1593195522, 3505876378}
local prefix = "/"
local LocalChatMessage = game.ReplicatedStorage.LocalChatMessage
local function checkCommand(player, message)
message = string.lower(message)
local args = string.split(message, " ")
if args[1] == prefix.."ban" then
print(args[2])
local id
local success, response = pcall(function()
id = game.Players:GetUserIdFromNameAsync(args[2])
end)
if success then
table.insert(bannedPlayers,id)
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully banned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully banned "..args[2]..".", false)
end
for _,player in ipairs(game.Players:GetPlayers()) do
if player.Name:lower() == args[2] then
player:Kick("get dunked on")
break
end
end
elseif args[1] == prefix.."unban" then
local id
local success, response = pcall(function()
id = game.Players:GetUserIdFromNameAsync(args[2])
end)
if success then
table.remove(bannedPlayers, table.find(bannedPlayers, id))
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully unbanned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully unbanned "..args[2]..".", false)
end
end
end
local function checkPlayer(player)
if table.find(bannedPlayers, player.UserId) then
player:Kick("You have been banned for")
return
end
if table.find(admins, player.UserId) then
player.Chatted:Connect(function(message)
checkCommand(player, message)
end)
end
end
game.Players.PlayerAdded:Connect(checkPlayer)
--//Services
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local PlayerStore = DataStoreService:GetDataStore("PlayerData")
local LocalChatMessage = ReplicatedStorage.LocalChatMessage
--//Controls
local admins = {"L6ker", "Peapod_iDTech"}
local prefix = "/"
--//Initialization
local getSuccess, bannedPlayers = pcall(function()
return PlayerStore:GetAsync("BannedPlayers")
end)
if not getSuccess and not bannedPlayers then
bannedPlayers = {}
local setSuccess, errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
end
--//Functions
local function checkCommand(player, message)
message = string.lower(message)
local args = string.split(message, " ")
if args[1] == prefix.."ban" then
print(args[2])
local id = nil
local success, response = pcall(function()
id = Players:GetUserIdFromNameAsync(args[2])
end)
if id then
table.insert(bannedPlayers,id)
local setSuccess, errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully banned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully banned "..args[2]..".", false)
end
for i, player in ipairs(Players:GetPlayers()) do
if player.Name:lower() == args[2] then
player:Kick("get dunked on")
break
end
end
elseif args[1] == prefix.."unban" then
local id = nil
local success, response = pcall(function()
id = Players:GetUserIdFromNameAsync(args[2])
end)
if id then
table.remove(bannedPlayers, table.find(bannedPlayers, id))
local setSuccess,errorMessage = pcall(function()
PlayerStore:SetAsync("BannedPlayers", bannedPlayers)
end)
LocalChatMessage:FireClient(player, "Successfully unbanned "..args[2]..".", true)
else
LocalChatMessage:FireClient(player, "Unsuccessfully unbanned "..args[2]..".", false)
end
end
end
local function checkPlayer(player)
if table.find(bannedPlayers, player.UserId) then
player:Kick("You have been banned for")
return
end
if table.find(admins, player.UserId) then
player.Chatted:Connect(function(message)
checkCommand(player, message)
end)
end
end
Players.PlayerAdded:Connect(function(player)
checkPlayer(player)
end)