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

Does't give points at first kill, but it does on second and so on?

when you kill someone u get points.. but it only give points after the first kill.

here 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 = "Coins"

local db = 0

Players.PlayerAdded:connect(function(Player)
	wait(1)
	local Stats = Template:Clone()
	Stats.Parent = Player
	Player.CharacterAdded:connect(function(Character)
		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
							if db == 0 then
							db = db + 1
							local Kills = Killer.leaderstats.Kills
							local Coins = Killer.leaderstats.Coins
							Kills.Value = Kills.Value + 1
							Coins.Value = Coins.Value + 2
							wait(1)
							db = db - 1
							else return end
						end
						return
					end
				end
			end)
		end
	end)
end)

1 answer

✓ Accepted answer

When someone joins their character gets added pretty quickly so the CharacterAdded event probably only gets called after the person resets, you should debug the CharacterAdded event to check if this is correct.

3 comments

0

oh ok wait

0

just checked, it was not the problem

0

wait it is the problem ok just fixed it thanks

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