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)
"If the number is greater than 0, then the player is banned."
So, you can simply save their value as 0 again.
function UnBan() local name = script.Parent.Player.Text name = game.Players:GetUserIdFromNameAsync(name) if name and not script.Parent.Parent:FindFirstChild("Pass") then banstore:SetAsync(name.."_ban",0) end end script.Parent.UnBan.MouseButton1Click:Connect(UnBan)