Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I unban someone from a DataStore?

I made this script

local BanData = game:GetService("DataStoreService"):GetDataStore("SaveBan")

script.BanEvent.OnServerInvoke = function(player, PlayerName)
	if game.Players:FindFirstChild(PlayerName) then
		game.Players:FindFirstChild(PlayerName).Banned.Value = true
		game.Players:FindFirstChild(PlayerName):Kick("Banned")
	end
end

script.UnBanEvent.OnServerInvoke = function(player, PlayerName)
	if game.Players:FindFirstChild(PlayerName) then
		game.Players:FindFirstChild(PlayerName).Banned.Value = false
	end
end

But obviously I can't use FindFirstChild to unban someone as they can't join the game. How would I change their Banned.Value when they're not in the game?

This is for my Admin GUI and I have made so you can type in the username and click Ban and It will ban them so how would I enter someones username and unban them when they can't join the game?

1 answer

You can save whether a player is banned or not using your data store. Save a value of true against the player’s UserId and simply revert it to false or nil when unbanning a player. Since you use the playerName, the Players:GetUserIdFeomNameAsync() method might be helpful to use.

This discussion is preserved as it was. New answers, comments, and votes are closed.