Hello i need help with datastores to ban people
i checked this post before i made my datastore:
i tried to do this script but when i fired the remote it always returned couldnt ban idk why
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("BanStore")
function saveBanData(plr)
local BanData = {}
local success, err = pcall(function()
DS:SetAsync(plr.UserId, BanData)
end)
if success then
print("banned")
elseif err then
print("couldnt ban")
end
end
function banfunction(plr)
plr:Kick()
saveBanData()
end
game.Players.PlayerAdded:Connect(function(plr)
local data
local success, err = pcall(function()
data = DS:GetAsync(plr.UserId)
end)
if success and data then
plr:Kick()
return
else
return
end
end)
game.ReplicatedStorage.BanRemote.OnServerEvent:Connect(banfunction)