Resetting a players Leaderstats

So I recently had a guy make about 17 accounts and run some type of exploit which allowed him to get quite a few coins. I’m actively working on implementing a an Anti Cheat but in the mean time I need to clear his leaderstats but he’s not online. If you might know of a post or something which allows you to clear their leaderstats and get them off the leaderboard while they’re offline then that would be very helpful Kind Regards ZoomCode.

1 Like

What do you mean by leaderstats? If it’s saved in a datastore then just use RemoveAsync with the key you used to save it.

Will that remove it for 1 player only tho?

Well it depends on how you’re modelling your DataStore. Are you saving the players data using their UserId as the key?

1 Like

Another thing is I need it to change it even tho he’s not online

You can change datastores in Studio even if they aren’t online.

local userKey = "1111111";
local dss = game:GetService("DataStoreService");
local userData = dss:GetDataStore("DataStoreName");

userData:RemoveAsync(userKey);

Edit that to match the userId and the correct datastore then run it in the studio command line.

1 Like

Nucl3ar is right, but are you trying to basically destroy this guy’s chances of ever gaining in your game again?

If so, do something a little like this:

--Credit to Nucl3ar, he gave me most of the code inside the function.--

function onAddedPlayer(player)
    if player.UserId = 1111111 then
        local userKey = "1111111";
        local dss = game:GetService("DataStoreService");
        local userData = dss:GetDataStore("DataStoreName");

        userData:RemoveAsync(userKey);
    end
end
game.Players.PlayerAdded:connect(OnAddedPlayer)

That way, if he joins, his stats get reset each time. He could spend an hour grinding, and then try to rejoin the next day and have all of it gone. This is a pretty harsh punishment, but if you want him to stop messing with your game by doing this.

4 Likes

Thank you i’m going to make sure to implement this!

Thanks resetting their data now!

Sweet, thanks so much for the great question!

Although I currently have him banned will the leaderstats still read his stats as gone?

Are you talking about a leaderboard or leaderstats as in the player list thing?

Yup, they should. They should read as 0, I guess.

In one session, he could gain 6 billion. My system doesn’t stop this, but don’t be alarmed - he can rejoin and he will have 0 again.

Alright last question could I do something like this?
function onAddedPlayer(player)
if player.UserId = 1111111,2222222,33333333 then
local userKey = “1111111,2222222,33333333”;
local dss = game:GetService(“DataStoreService”);
local userData = dss:GetDataStore(“DataStoreName”);

    userData:RemoveAsync(userKey);
end

end
game.Players.PlayerAdded:connect(OnAddedPlayer)

So, what you’d want to do is here:

function onAddedPlayer(player)
    if player.UserId = 1111111 then
        local userKey1 = "1111111";
        local userKey2 = "222222";
        local userKey3 = "333333"
        game:GetService("DataStoreService");
        local userData = dss:GetDataStore("DataStoreName");

        userData:RemoveAsync(userKey1);
        userData:RemoveAsync(userKey2);
        userData:RemoveAsync(userKey3);
    end
end
game.Players.PlayerAdded:connect(OnAddedPlayer)

So, to my knowledge, this is the most efficient way, but this might not be. Either way, this should work.

I think he means for multiple users since in the OP he mentioned multiple accounts.
This can be achieved as such:

local affectedPlayers = {[1111]=true,[2222]=true};
local dss = game:GetService("DataStoreService");
local userData = dss:GetDataStore("DataStoreName");

game.Players.PlayerAdded:Connect(function(player)
	if (affectedPlayers[player.UserId] == true) then
		userData:RemoveAsync(player.UserId);
	end
end)

This should work perfectly only problem is I already banned them and I tried getting off the leaderboard with that script you gave me but it didn’t seem to do anything. Any ideas on anything else I could try to clear their stats from the serverconsole in game?

Yeah, I guess that would be better suited. Thanks!

You really need to be clear with what you mean by leaderboard. Could you link the game in question?

https://www.roblox.com/games/3336615417/Island-Jump-BETA