Just wanted to make a ban datastore today, and i feel like i'm missing something on the code. Seems to not work in roblox with api services enabled. <--- Problem
local DataStore = game:GetService("DataStoreService")
local ds1 = DataStore:GetDataStore("BanDataStore")
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder",player)
folder.Name = "PlayerValues"
local banvalue = Instance.new("BoolValue",folder)
banvalue.Value = false
banvalue.Name = "BanValue"
end)
--SetAsync.Ban
game.Players.PlayerRemoving:Connect(function(player)
if player.PlayerValues.BanValue.Value == true then
ds1:SetAsync(player.UserId, player.PlayerValues.BanValue.Value)
--BanCheck
ds1:GetAsync(player.UserId, player.PlayerValues.BanValue.Value)
if player.PlayerValues.BanValue.Value == true then
player:Kick("Banned.")
end
end
end)

3 comments
Funny that you say that, I am writing a ban system for my game using data stores.
^ Good luck writing it mate.
I know.