this is just a repost but theres a message when i try to ban myself or other people
and heres the main script
local ps = game:GetService("Players")
function convertDaysToSecends(days)
return 86400 * tonumber(days)
end
function convertHoursIntoSecends(hours)
return 3600 * tonumber(hours)
end
local AllowedPeople = {
1813216757,
1915724787,
1029123331,
2728185622,
}
game.ReplicatedStorage["Banny_Binny!"].OnServerEvent:Connect(function(player, bannedplr, banrsn, bandur)
if not table.find(AllowedPeople, player.UserId) then return end
print(tonumber(bandur))
local plr = ps:FindFirstChild(bannedplr)
local config: BanConfigType = {
UserIds = {player:WaitForChild("PlayerGui").Admn.Frame.TextBox.Text}, -- couldnt get this to a pcall statement :()
tonumber(bandur),
DisplayReason = banrsn,
PrivateReason = bannedplr.." Got Banned Because of:"..banrsn
}
local success, errorMessage = pcall(function()
return ps:BanAsync(config)
end)
if success then
print("THE ALMIGHTY BAN CAME")
else
warn(errorMessage)
end
end)
On the BanAsync function, on UserIds, you are trying to get the userId from you Gui TextBox, but the text is only locally.
Here is the fix:
local ps = game:GetService("Players")
function convertDaysToSecends(days)
return 86400 * tonumber(days)
end
function convertHoursIntoSecends(hours)
return 3600 * tonumber(hours)
end
local AllowedPeople = {
1813216757,
1915724787,
1029123331,
2728185622,
}
game.ReplicatedStorage["Banny_Binny!"].OnServerEvent:Connect(function(player, bannedplr, banrsn, bandur)
if not table.find(AllowedPeople, player.UserId) then return end
print(tonumber(bandur))
local BannedPlayer = ps:FindFirstChild(bannedplr) -- Gets the banned player.
local config: BanConfigType = {
UserIds = {BannedPlayer.UserId}, -- Correct UserId
tonumber(bandur),
DisplayReason = banrsn,
PrivateReason = bannedplr.." Got Banned Because of:"..banrsn
}
local success, errorMessage = pcall(function()
return ps:BanAsync(config)
end)
if success then
print("THE ALMIGHTY BAN CAME")
else
warn(errorMessage)
end
end)