This script is supposed to reset the players coins and kick them if they have over 60000, player:kick works but coins are not reset

local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("CoinsLeaderboard")
local player = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(player)

    repeat wait() until player:FindFirstChild("leaderstats")

    player.leaderstats.Coins.Changed:Connect(function()
        if player.leaderstats.Coins.Value >= 60000 then
                local Key = player.UserId
            DataStore:RemoveAsync(Key)
            player:Kick("Exploiting")
            end
end)
end)

There is this error for the RemoveAsync

DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests

Why dont you return the script after you kick the player? This is like a debounce and it will only call the datastore once.

2 Likes

That’s a warning not an error, hence it’s displayed in orange text rather than red.

Avoid issuing multiple requests to the same DataStore instance with the same key in quick succession.

I would recommend having your save function do the work for you, just set the value to zero and the save function will overwrite it to the data store

1 Like