Is stealing leaderboard stats possible?

so, what I mean is say you’re making a bounty system and when you kill another player you get 100 bounty AND you steal half of their bounty. I know you can give the 100 but can you take someone else’s stats?
I’ve looked all over the YouTube, Google, and DevForum and haven’t found anything about this topic. could you possibly help me out?

2 Likes

You could loop through the players stats and divide each one by 2, then take those and add them to the receiving player’s stats. If you need me to, I can provide an example.

2 Likes

That would be lovely. If you’re willing. Oh, and thanks by the way.

1 Like

Yes, it is possible.
I hope I understood you correctly.

Here is an example:

local Humanoid = script.Parent.Humanoid
local Players =game:GetService("Players")
local Player=Players:GetPlayerFromCharacter(script.Parent)

--NOTES:
--Player is YOU
--tag.Value is the PLAYER THAT KILLED YOU

local function onDied() 
	local tag = Humanoid:findFirstChild("creator") 
	if tag ~= nil then 
		if tag.Value ~= nil then 
           local Leaderstats = tag.Value:findFirstChild("leaderstats") 
			if Leaderstats ~= nil then 
				Leaderstats.bounty.Value += 100
				Player.leaderstats.bounty.Value /= 2
				task.wait(1)
                script:Destroy()
			end 
		end 
	end 
end
Humanoid.Died:connect(onDied)  




4 Likes

I’ll have to test it out, thank you so much

1 Like

Ex:

local function GetStats(player)
	local PlayerStats = {}
	for i, Stat in pairs(player.Stats:GetChildren()) do --//Loop through folder called Stats in player.

		PlayerStats[Stat.Name] = Stat.Value --//Put Stat in table
	end
	return PlayerStats --//Return Stats table.
end

local function GiveStats(RecievingPlayer, KilledPlayer)
	local RecievingPlayerStats = GetStats(RecievingPlayer) --//Get Stats
	local KilledPlayerStats = GetStats(KilledPlayer) --//Get Stats
	
	for i, Stat in pairs(KilledPlayerStats) do
		KilledPlayerStats[Stat] = KilledPlayerStats[Stat] / 2
		RecievingPlayerStats[Stat] = RecievingPlayerStats[Stat] + KilledPlayerStats[Stat]
	end
	
	for i, Stat in pairs(RecievingPlayer.Stats:GetChildren()) do --//Loop through folder called Stats in player.

		Stat.Value = RecievingPlayerStats[Stat.Name]
	end
end

I see @Valkyrop beat me to it but the GiveStats function would take all the values in a player’s Stats folder and add half to the RecievingPlayer’s Stats. You just have to fire the function with the two players you want using a Humanoid.Died or whatever you need.

4 Likes

lol, thank you both so much I’ll give both of yours a try.

1 Like