Hello there I’m a new scripter here,
I’m trying to make a script here where I can pban people by their ID, I had an old scripter on my team that made a script that could pban people but only if they were on the Server.
He made his own datastore to keep the gamebans and the people’s name I tweaked it a bit and here it is.
I’m Using CMDR!
CommandServer
local TextService = game:GetService("TextService")
local Players = game:GetService("Players")
return function (context, playerId, reason)
local Response = nil
local peche = require(game.ServerScriptService.Peche.Peche)
local success, response = pcall(function()
Response = peche.PermBan(playerId)
end)
if success then
return "Player has been succesfully banned!"
else
return "Something went wrong, sorry!"
end
end
Datastore
local Peche = {}
Peche.PermBan = function(Player, reason, moderatorString)
local dss = game:GetService("DataStoreService")
local bansdatastore = dss:GetDataStore("GameBans")
local bantable = {}
bantable.Reason = reason
bantable.Moderator = moderatorString
bansdatastore:SetAsync(Player.UserID, bantable)
Player:Kick("You have been permanently banned from the game. Reason: " .. reason .. " | Moderator: " .. moderatorString)
end
Datastore Server
game.Players.PlayerAdded:Connect(function(player)
local dss = game:GetService("DataStoreService")
local bansdatastore = dss:GetDataStore("GameBans")
if bansdatastore:GetAsync(player.UserId) then
local banTable = bansdatastore:GetAsync(player.UserId)
player:Kick("You have been permanently banned from the game. Reason: " .. banTable.Reason .. " | Moderator: " .. banTable.Moderator)
end
end)
When I try to run the command it returns with “Something went wrong, sorry!”
Please someone help me!