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

Why do the Points stop increasing after first KO?

Hello! The script below will successfully add points to my leaderboard after a player first kills another player. But, if they kill more, the points will not exceed the values below. Or if they exceed it once, like when the player is awarded points for surviving the round, the very next round when they kill another player, it reverts back to the values below. How can I make the values increase per kill? Thank you!

Players = game:GetService('Players')
Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
local Humanoid = Character:WaitForChild('Humanoid')
Humanoid.Died:connect(function()
if Humanoid:FindFirstChild('creator') ~= nil then
local Killer = Humanoid.creator.Value
Killer.leaderstats.Points.Value= Player.leaderstats.Points.Value+100 
Killer.leaderstats.EXP.Value= Player.leaderstats.EXP.Value+350 	
end       
end)   
end)      
end)

1 comment

0

any output? and why are you doing lines 8 and 9 like that? Killer.Leaderstats, then Player.Leaderstats

1 answer

✓ Accepted answer

Hello, Never2Humble!

Before, I used to have that same issue, and I solved it myself. I'll share with you my personal script, of earning Points/XP for each kill.

game.Players.PlayerAdded:connect(function(newPlayer)
local humanoid = script.Parent.Humanoid
script:clone().Parent = humanoid.Parent
function PwntX_X() 
	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.Credits.Value = leaderstats.Credits.Value + 5
				leaderstats.EXP.Value = leaderstats.EXP.Value + 5
				wait(0.1) 
				script:remove() 
			end 
		end 
	end 
end 

humanoid.Died:connect(PwntX_X) 

If it does not work, Please feel free to ask!

1 comment

0

It worked!!!! :D With just a bit of tweaking, it worked! Thank you good sir! Thank you!

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