elseif SplitCommand[1] == ":unban" or SplitCommand[1] == ":Unban" then
local TargetedPlayer = SplitCommand[2]
local Name = game.Players:FindFirstChild(TargetedPlayer)
Here’s some of my code but if a palyer’s banned they can’t join back… so how would this unban them? But like how would I make it when I type the player’s username it will unban them EVEN if they’re offline or not in game (since if ur banned u can’t join back) I’m not asking for how to make it unban someone I’m asking for how can it detect a player even if they’re not in game since they’re banned
You already have the piece of code to find a player.
--Like these:
local Players = game:GetService("Players")
if Players:FindFirstChild(TargetPlayer) then
-- player found in the server.
else
-- player not found in the server.
end
I not talking bout that. I mean since they’re banned it’s gona unban them but when typing their user they won’t be in a server. So how can I make it when the player is offline since they cant join the game back since they banned
local TargetedPlayer = SplitCommand[2]
-- // Assuming you store userids in the datastore,
local userid = game.Players:GetUserIdFromName(TargetedPlayer)
datastore:RemoveAsync(userid)
-- you mightve added a suffix or a prefix to the key, add that id u did
--Unban Player
elseif SplitCommand[1] == ":unban" or SplitCommand[1] == ":Unban" then
local TargetedPlayer = SplitCommand[2]
local Name = game.Players:FindFirstChild(TargetedPlayer)
BanDataStore:RemoveAsync(TargetedPlayer)
--Unban Player
--Unban Player
elseif SplitCommand[1] == ":unban" or SplitCommand[1] == ":Unban" then
local TargetedPlayer = SplitCommand[2]
local Name = game.Players:FindFirstChild(TargetedPlayer)
BanDataStore:RemoveAsync(TargetedPlayer)
--Unban Player
-Ban Player
elseif SplitCommand[1] == ":ban" or SplitCommand[1] == ":Ban" then
local TargetedPlayer = SplitCommand[2]
local Name = game.Players:FindFirstChild(TargetedPlayer)
Name:Kick("You have been banned by a Blossom County Moderator. To appeal, join our Discord server linked below our game.")
local Success, ErrorMessage = pcall(function()
BanDataStore:SetAsync(Player.UserId, true)
end)
if Success then
Player:Kick("You have been banned by a Blossom County Moderator. To appeal, join our Discord server linked below our game.")
else
warn(ErrorMessage)
end
--Ban Player
--Check if player is banned
game.Players.PlayerAdded:Connect(function(Player)
local Banned
local Success, ErrorMessage = pcall(function()
Banned = BanDataStore:GetAsync(Player.UserId)
end)
if Banned == true then
Player:Kick("You have been banned by a Blossom County Moderator. To appeal, join our Discord server linked below our game.")
end
if Success then
else
warn(ErrorMessage)
end
end)
--Check if player is banned
--Unban Player
elseif SplitCommand[1] == ":unban" or SplitCommand[1] == ":Unban" then
local TargetedPlayer = SplitCommand[2]
local Name = game.Players:FindFirstChild(TargetedPlayer)
Ban:SetAsync(TargetedPlayer.UserID, false)
--Unban Player
When the player was offline and I did :unban in the chat they were still banned. Any solutions?
```lua
--Unban Player
elseif SplitCommand[1] == ":unban" or SplitCommand[1] == ":Unban" then
local TargetedPlayer = SplitCommand[2]
local Name = game.Players:FindFirstChild(TargetedPlayer)
Ban:SetAsync(TargetedPlayer.UserID, false)
--Unban Player