I am trying to make a command that awards points to the killer if the killer kills someone, but instead of giving the points to the killer, it gives it to the person that dies. How do I fix this? (line 25 is where the conditioning is done) (In case there is confusion or if it helps, KillerTag is an Int value I placed in people. Also, the amount of points do correlate to the right person, it's just that the pair of who should be getting the points is chosen wrong)

function awardpoints(player,points)
	if player and points then
		local leaderstats = player:FindFirstChild("leaderstats")
		if leaderstats then
			local pointsvalue = leaderstats:FindFirstChild("Points")
			if pointsvalue then
				pointsvalue.Value = pointsvalue.Value + points
				
			end
		end
	end
end
function awardexp(player,exp)
	if player and exp then
		local leaderstats = player:FindFirstChild("leaderstats")
		if leaderstats then
			local expvalue = leaderstats:FindFirstChild("exp")
			if expvalue then
				expvalue.Value = expvalue.Value + exp
				
			end
		end
	end
end
game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			local tag = character.Humanoid:FindFirstChild("creator")
			if tag ~= nil then
				if tag.Value then
					local KillerTag = character:FindFirstChild("KillerTag")
					if KillerTag then
						awardpoints(player,50)
						awardexp(player,100)
					else
						awardpoints(player,-500)
						awardexp(player,-1000)
					end
				end
			end
		end)
	end)
end)

2 comments

0

On lines 32-37, it looks like you're passing the "player" variable through your functions, which is associated with the player that has that event listener. Try replacing player with KillerTag.Value instead.

0

@Bobbrige Do you mean on line 33 34 or line 32, I tried both and It gave the rewards listed in the else section, which isn't affected by those three lines and is meant for those who not in that specific category that has KillerTag