I am trying to fix this problem but I get so confused please help me. If it is possible please Help.
✓ ANSWER ACCEPTED
Is it possible to make a Ban Function using Data Store?
2 answers
✓ Accepted answer
Yes it is possible
Here is an example:
--Server Script
local datastore = game:GetService("DataStoreService"):GetDataStore("Bans")
game.Players.PlayerAdded:connect(function(plr)
local key = "user_" .. plr.UserId
local banned = Instance.new("BoolValue", plr)
banned.Value = datastore:GetAsync(key) or false
banned.Name = "Banned"
if banned.Value == true then
plr:Kick("You have been banned!")
end
banned.Changed:connect(function()
datastore:SetAsync(key, banned.Value)
if banned.Value == true then
plr:Kick("You have been banned!")
end
end)
end)
how can the code you posted be made to ban players if they try to use commands?
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
yes