I need help with datastores. I figured out how to ban a player with datastores, but how would I unban that player? This below is how the ban works and how a person gets banned in-game. If the number is greater than 0, then the player is banned. How would I write code that would unban the player without the player being in the game?
_G["bandata"] = "byeskid"
local banstore = game:GetService("DataStoreService"):GetDataStore(_G.bandata)
function onPlayerEntered(player)
local ban = banstore:GetAsync(player.userId .. "_ban")
if ban and ban > 0 then
player:Kick()
end
end
--------BAN-PLAYER--------
function Ban()
local name = script.Parent.Player.Text
if name and not script.Parent.Parent:FindFirstChild("Pass") then
local banned = game.Players:FindFirstChild(name)
if banned then
banstore:SetAsync(banned.userId .. "_ban", 3)
banned:Kick()
end
script.Parent.Player.Text = " "
end
end
script.Parent.Ban.MouseButton1Click:connect(Ban)

2 comments
Addendum, if you want to be able to use the name you can use http://wiki.roblox.com/index.php?title=API:Class/Players/GetUserIdFromNameAsync
Nice tip ;D