Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to increase 2 IntValues from leaderboard at once?

heres what i want:

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 = "Bux"


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 -- but also "Bux" here, i can only grab "Kills" but not both.
							local Kills = Killer.leaderstats.Kills
							local Bux = Killer.leaderstats.Bux
							Kills.Value = Kills.Value + 1
							Bux.Value = Bux.Value + math.Random(15,25)

						end
						return
					end
				end
			end)
		end
	end)
end)

what i try to do is increase 2 int values from the leaderboard when a kill is made but is there another instance than findfirstshild so that i can increase both instead of 1?

3 comments

0

"Template" is never given a parent. Therefore, Template and its descendants remain in thin air.

0

the script still works fine to me

0

only bux value won't increase after kill event

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.