Hi, I am trying to make a ban-panel where the kick function already works. But I don’t know how I can make the script know how long days, hours and minutes are. Do I need to make a data store or something diffrent? I really need help at making this. Here’s the script:
local Admins = {
0,
0,
0, -- these are the admins
}
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local KickEvent = ReplicatedStorage:WaitForChild("Kick")
local CheckIfAdmin = ReplicatedStorage:WaitForChild("CheckPlayer")
local shutdown = ReplicatedStorage:WaitForChild("Shutdown")
local KickAllPlayers = ReplicatedStorage:WaitForChild("KickAllPlayers")
local BanEvent = ReplicatedStorage:WaitForChild("Ban")
local manualBan = {}
local DateStoreService = game:GetService("DataStoreService")
local banDataStore = DateStoreService:GetDataStore("banDataStore")
BanEvent.OnServerEvent:Connect(function(player, PlayerName, Reason, days, hours, minutes)
-- I really dont know how I can make the script know how long days, hours and minutes are.
if table.find(Admins, player.UserId) then
local playerFound = Players:FindFirstChild(PlayerName)
local playerUserId = player.UserId
local banned
local succes, errormessage = pcall(function()
banned = banDataStore:GetAsync(playerUserId)
end)
if playerFound then
if playerFound.Name == "PVP_Player2373902" or playerFound.Name == "Tastysam_lol" then
warn("Unable to ban Player!")
return
else
playerFound:Kick(Reason)
task.wait(3)
if game.Players:FindFirstChild(PlayerName) == true then
warn("Error while kicking player!")
return
end
end
end
else
player:Kick("PUT YOUR HAND AWAY FROM MY ADMIN-PANEL") -- this happens if a non-admin is using the kick/ban-panel
end
end)
game.Players.PlayerAdded:Connect(function(player) -- this is supposed to kick a player who is banned.
local playerUserId = player.UserId
if manualBan[playerUserId] then
player:Kick("You are still banned because of:... Bantime left: ...d ...h ...s")
end
local banned
local succes, errormessage = pcall(function()
banned = banDataStore:GetAsync(playerUserId)
if banned == true then
player:Kick("You are banned! Reason:... Length:...")
end
end)
end)
I have described some script lines so you can understand this script better.
I would appreciate any help.