I' ve recently been messing arround with leaderstats, I' ve inserted the following script into a Script in Workspace. I can' t get XP after kills, either rank up once reaching 1000 XP... this is the script.

local Players = game.Players

local Template = Instance.new 'BoolValue'
Template.Name = 'leaderstats'

Instance.new('IntValue', Template).Name = "Kills"
Instance.new('IntValue', Template).Name = "Deaths"
Instance.new('IntValue'. Template).Name = "Rank"
Instance.new('IntValue'. Template).Name = "XP"


Players.PlayerAdded:connect(function(Player)
	wait(1)
	local Stats = Template:Clone()
	Stats.Parent = Player
	local Deaths = Stats.Deaths
	Player.CharacterAdded:connect(function(Character)
		Deaths.Value = Deaths.Value + 1
		local Humanoid = Character:FindFirstChild "Humanoid"
		if Humanoid then
			Humanoid.Died:connect(function()
				for i, Child in pairs(Humanoid:GetChildren()) do
					if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
						local Killer = Child.Value
						if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then
							local Kills = Killer.leaderstats.Kills
							Kills.Value = Kills.Value + 1
						if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "XP" then
							XP.Value = XP.Value + 250
							if XP.Value = 1000 then
								Rank.Value = Rank.Value + 1
							end
						end
						end 
						return
					end
				end
			end)
		end
	end)
end)

1 comment

0

Scripting helpers is a site for helping people with code self made, not code you didn’t make from free models.