How would I make a ban system where when someone gets banned:
DataStore:SetAync(userid, reason)
Now how would I check if they are banned?
How would I make a ban system where when someone gets banned:
DataStore:SetAync(userid, reason)
Now how would I check if they are banned?
So I do:
local data = DataStore:GetAsync(userid)
if data = nil then
else
player:Kick(data) -- Data would be the reason I saved above
Would that work?
You can simplify it to if (data) then
because everything except nil
and false
have truthiness.
local data = DataStore:GetAsync(userId)
if (data) then
player:Kick(data)
end
If you wanna ban someone then simply do
MyData:SetAsync(playerToBan.UserId,true) --true is a boolean value, set to false if you dont want them banned.
playerToBan:Kick("bye")
function onPlayerAdded(plr)
local data
pcall(function()
if MyData:GetAsync(plr.UserId) == true then--at the code above we setted it to true so that when the rejoin they get banned.
plr:Kick("BANNED")
end
end)
end