Problem at bans in a admin script made by me

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

i want to make a admin script but the ban sistem don’t save, instead of waiting a day to get unbanned it dont works and only kick u

  1. What is the issue? Include screenshots / videos if possible!

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

no, i don’t think there thinks u can find in Developer Hub

please can someone to say what i made wrong?

the script is:

‘’'local Day1 = 86400
local Day1Value = “1 Day”

–// AdminTable \–-
AdminModule = require(game.ReplicatedStorage.AdminModule)
Admins = AdminModule.Admins
Banned = AdminModule.Banned
Banned1Day = AdminModule.Banned1Day
–// VerifyBann \–-
local savebanns = game:GetService(“DataStoreService”)
local data = savebanns:GetDataStore(“Banns”)
local addata = savebanns:GetDataStore(“Admins”)
–// Custom function \–-
local function Banned1DayF(Player)
local timeuntilunban = Player:FindFirstChild(“timeuntilunban”)
local PLR = Player.Name
table.insert(Banned1Day, PLR)
timeuntilunban.Value = Day1
wait(0.01)
data:SetAsync(“Banns”, Banned1Day)
Player:Kick(“You has ben banned, wait ‘1 Day’ to get unbanned!”)
os.time(Day1)
table.remove(Banned1Day,PLR)
end
local function BannedKick(Player,Time)
if table.find(Banned1Day, Player.Name) then
local Time = os.time(Day1)
game.Players[Player]:Kick(“You has ben banned, wait “…Time…” to get unbanned!”)
end
end
local function Kick(Player,AdminName)
game.Players[Player]:Kick(“You has ben kicked by “…AdminName…” if u want to raport he, text at me with his name and what he do”)
end
–// Sistem \–-

local function TIme(plr)
if table.find(Banned1Day, plr.Name) then
local Time = os.time(Day1)
end
end

local function ifbanned1day(plr)
if table.find(Banned1Day, plr.Name) then
plr:FindFirstChild(“Banned1Day”).Value = true
else
plr:FindFirstChild(“Banned1Day”).Value = false
end
end

local datastore = game:GetService(“DataStoreService”):GetDataStore(“TIME”)

–// Chat Sistem \–-
local function TeleportGui(plr)
local GuiClo = game.ReplicatedStorage.Admin.AdminGui:Clone()
GuiClo.Parent = plr.PlayerGui
end
local msg1 = “!Admin Me”
local function Warn(WarnText)
warn(WarnText)
end
game.Players.PlayerAdded:Connect(function(plr)
local timeNow = os.time()

local data

pcall(function()
 data = datastore:GetAsync(plr.UserId.."-Ban")
end)


if data ~= nil then
	local TimeSinceLastClaim = timeNow - data
	
	if (TimeSinceLastClaim / 3600) >= 24 then
		table.remove(Banned1Day, plr.Name)
		savebanns:SetAsync(plr.UserId.."-Ban")
	else
		
	end
end

local ban = Instance.new("BoolValue", plr)
local timeuntilunban  = Instance.new("IntValue", plr)
timeuntilunban.Name = "timeuntilunban"
ban.Name = "Banned1Day"
ban.Value = ifbanned1day(plr)
if table.find(Admins,plr.Name) then
	warn("A admin called "..plr.Name.." Has joined")
	plr.Chatted:Connect(function(msg)
		if msg == msg1 then
			TeleportGui(plr)
		end
	end)
end

if table.find(Banned, plr.Name) and table.find(Admins,plr.Name) then
	warn("A admin can't be banned or kicked")
elseif table.find(Banned, plr.Name) and not table.find(Admins, plr.Name) or not table.find(Admins, plr.Name) and plr.Banned1Day.Value == true then
	BannedKick(plr, TIme(plr))
end

end)

game.ReplicatedStorage.Admin.Ban1Day.OnServerEvent:Connect(function(Player)
Banned1DayF(Player, Day1Value)
end)

game.Players.PlayerRemoving:Connect(function(plr2)
data:SetAsync(“Banns”, Banned1Day)
end)

game.Players.PlayerRemoving:Connect(function(plr3)
local data
pcall(function()
data = savebanns:GetAsync(plr3.UserId…“-Ban”)
end)

if data == nil then
	pcall(function()
		local TimeVal = os.time()
		savebanns:SetAsync(plr3.UserId.."-Ban")
	end)
	print("New Player")
end

end)‘’’

I am pretty sure that your data isn’t saving. I would rewrite the datastore with DataStore2 which thread can be found here:

1 Like

i tryed that but i don’t know how to use it, i wached alvinblox and more youtubers to learn but when i try to make same it warn i dont save it

Please give me a DM at Discord: zanluka#2610 I’ll teach you how to use it properly.

2 Likes

Hi! Could you please format your code so it’s easier to assist you in the future? You can put your code in a codeblock by using three backticks (`) which can be found right below the Escape key in the top left.

1 Like

You shouldn’t store that admin module in replicatedstorage, as clients can read it and also do not store things via the players name as it is a bad habbit and will cause problems down the line, use Player.UserId.

1 Like

Yeah but im bad at user id thats why i use username

I put they but idk why created this, îs my script too long?

Those are not backticks. You used single quotation marks. Backticks look like ` not '. Look on your keyboard under the escape key.

1 Like

I used ‘’’
At start and ‘’’ at finish

1 Like

Nothing to do with this topic specifically but this might, possibly help with formatting stuff (if you haven’t figured it out already) https://devforum.roblox.com/t/guide-to-using-the-developer-forum/107263/6?u=jaycbee05

1 Like

To get a UserId, you can either go to a user’s profile and copy the numbers in the URL (users/USERID/profile) or use the function Players.GetUserIdFromNameAsync. You should always work in UserId when it comes to player-based coding. The name should only be used in cases where you need to display something.

Furthermore, you should look into code formatting. Without it, it makes it significantly difficult to help you resolve this. You can format your code by placing two sets of ``` (three backticks) and then the code you want underneath.

Example:

```lua
Your code
```

Like @colbert2677 said, you have to use backticks. You still are using quotation marks. Please look carefully, you are using these ‘’ instead of `. You should be using the one under your escape key not the one near the enter button.

1 Like