So i’ve tried to make a Panel, and make it as Secure as Possible By putting the Gui, in ServerStorage, and Cloning it in ServerScriptService and Making Remote Events that Can be triggered by Exploits and all.
but Im trying to make a Ban System if these Remote Events were triggered by putting Your UserId into a DataStore, But I can’t find a Way to Put their Id into the Datstore, and Remove it when their Time Finished
My Code
Create.OnServerEvent:Connect(function(plr, Text, item)
if plr.UserId == 2490493721 or 1169952399 then
else
plr:Kick("You Have Been Banned For: Attempting to Exploit to the Developer only Panel")
local data = BanDS:GetAsync(plr.UserId)
if data then
--Don't Know What to Do After this
end
end
end)```
I Notice, I Didn’t Explain well, So what i meant is If you triggered a Remote Event then it will Put Your UserId Into a DataStore, and After a Specific Time, it Removes you from the Datastore Using RemoveAsync()
Also, My Friends Say, That people Can’t Get to the Panel As Its Already Secured enough Because Its Cloned By the Server, and it’s Stored in ServerStorage
If you have no data stored into the datastores, you can always make it have the values: true or false.
So in your section, you can write:
if data then
local data = {true, 100)
BanDS:SetAsync(plr.UserId, data)
end
I saved the data as true (they are banned), and I added 100, as in 100 seconds. Then, you would have to use SubscribeAsync or something along the lines of that, and count the timer on the global datastore or somewhere that will continue counting even after the server is closed. After that timer is done, set the async as: {false, 0}
Do i Have To Use SubScribeAsync
Since I was Using a Reference on a Ban System
the Code for it
local admins = {2490493721, 1169952399, 390496682} -- Change to your ID
local ds = game:GetService("DataStoreService"):GetDataStore("Bans/Unbans")
game.Players.PlayerAdded:Connect(function(plr)
local data = ds:GetAsync(plr.UserId)
local IsAdmin = false
for i,v in pairs(admins) do
if v == plr.UserId then
IsAdmin = true
local clone = script.BanGui:Clone()
clone.Parent = plr.PlayerGui
end
end
if data then
if IsAdmin == false then
if data[1] == true then
plr:Kick("You have been banned from this game, reason: "..data[2])
end
end
end
end)
game.ReplicatedStorage:WaitForChild("Ban/Unban").OnServerEvent:Connect(function(plr, plrtoban, reason, ban)
if ban == "Ban" then
for i,v in pairs(admins) do
if plr.UserId == v then
if game.Players:FindFirstChild(plrtoban) then
if game.Players[plrtoban].UserId ~= plr.UserId then
print(plrtoban.." has been banned!")
game.Players[plrtoban]:Kick("You have been banned from this game, reason: "..reason)
ds:SetAsync(game.Players[plrtoban].UserId, {true, reason})
else print("This player is an admin!")
end
else
local players = game:GetService("Players")
local Id = players:GetUserIdFromNameAsync(plrtoban)
if Id ~= plr.UserId then
ds:SetAsync(Id, {true, reason})
print(plrtoban.." has been banned!")
end
end
end
end
elseif ban == "Unban" then
local players = game:GetService("Players")
local Id = players:GetUserIdFromNameAsync(plrtoban)
ds:RemoveAsync(Id) --Uses :RemoveAsync()
print(plrtoban.." has been unbanned!")
end
end)
Well this code could work, but if the server closes then the players will be banned forever, because the data is only stored on that server. You may or may not have to use subscribeasync, since it is the only way I know how to count a timer on the global servers.
Because I Was Using this as a Security, for my Dev Panel, and People Say it’s Already Secured
Since the Gui, is In ServerStorage
and I Clone the Gui in ServerScriptService