0

Basically I'm trying to make a banscript, but whenever I hit play on Roblox Studio it tells me the follwing: DataStore request was added to queue. If request queue fills, further requests will be dropped.

And any Datastore changes I try to make using scripts do not do anything. (I am only saving boolean values so it's not too much data!) BanHandler

    local DataStoreService = game:GetService("DataStoreService")
    local BanDataStore = DataStoreService:GetDataStore("BanDataStore")
          
    script.Parent.Ban.Event:Connect(function(Player : Player)
        BanDataStore:SetAsync(Player.UserId, true)
        print(tostring(Player.UserId).." has been banned!")
        Player:Kick("Banned.")
    end)
          
    script.Parent.Unban.Event:Connect(function(Player : Player)
        BanDataStore:SetAsync(Player.UserId, false)
    end)
             
          

DatastoreHandler -- DatastoreHandler

    game.Players.PlayerAdded:Connect(function(player)
        local DatastoreService  = game:GetService("DataStoreService")
        local BanDataStore = DatastoreService:GetDataStore("BanDataStore")
           
        BanDataStore:SetAsync(2528182795, false)
        
           
           
        local UserId = player.UserId
        local result = BanDataStore:GetAsync(UserId)
             
                     
        if result then
            player:Kick("You have been banned from this game!")
        end
                    
        if not result then
            BanDataStore:SetAsync(UserId, false)
        end
    end) 
goodbee
  • 3
  • 3
  • This is a warning, not an error. Warnings like this are the ones you don't need to worry about; no one is going to ban a lot of people that quickly. Are you trying to ban many people in a short amount of time? As far as I know, even if you make 2 requests one will get added to queue. – Random Jul 20 '22 at 19:14
  • That really wasn't the main thing, the banhandler doesn't save anything to the datastore, that is my problem. Thanks, still! – goodbee Jul 21 '22 at 08:29

2 Answers2

0

Is this because you are setting your own account to be unbanned?

BanDataStore:SetAsync(2528182795, false)

Try commenting this out and see if it works.

MobiDev
  • 154
  • 5
0

Instead of saving boolean values to create a ban script you can just use a table of banned player ids and iterate through it. For example,

local Players = game:GetService("Players")

local bannedPlayers = {
    -- Include player IDs of people that you want banned
    
}

Players.PlayerAdded:Connect(function(player)
    for i, v in pairs(bannedPlayers) do
        if v == player.UserId then
            player:Kick()
        end
    end
    
end)

If you want to tie this in with a data store for some reason then you could do

local DataStoreService = game:GetService("DataStoreService")
local BanDataStore = DataStoreService:GetDataStore("BanDataStore")

local bannedPlayers = {
    -- Include player IDs of people that you want banned
    1366289010 -- My UserID lol
}

game.Players.PlayerAdded:Connect(function(player)
    local playerUserId = "Player_"..player.UserId
    local data = {}
    
    local success, errormessage = pcall(function()
        data = BanDataStore:GetAsync(playerUserId, data)
    end)
    
    if success then
        for i, v in pairs(data) do
            if v == player.UserId then
                player:Kick()
        
            end
            
        end
        
    end
    
end)

game.Players.PlayerRemoving:Connect(function(player)
    local playerUserId = "Player_"..player.UserId
    
    local data = bannedPlayers
    
    local success, errormessage = pcall(function()
        BanDataStore:SetAsync(playerUserId, data)
    end)
    
    if success then
        print("Data saved successfully!")
    else
        warn(errormessage)
    end
    
end)

I'm kind of confused on the .Event code you wrote but you could alter your ban event and unban event to work with this data store by putting

script.Parent.Ban.Event:Connect(function(Player : Player)
    table.insert(bannedPlayers, Player.UserId)
end)

script.Parent.Unban.Event:Connect(function(Player : Player)
    table.remove(bannedPlayers, Player.UserId)
end)

Hope this helps! If you have any further questions, feel free to ask.