Adding Points Based On Death Order Error

Hello,
I was recently working on a script that would add points depending on which order the players died in but when the player dies it doesn’t add the points and there is no error code. Could anyone help me fix my code?
`
local Players = game:GetService(“Players”)
local points = 60
local playersTaken = {}
local blacklist = {88851721}
local function onPlayerAdded(player)
local function onCharacterAdded(character)
local humanoid = character:WaitForChild(“Humanoid”)

	local function onDied(plr)
			if game.ServerScriptService.activate.Enabled==false then return end
			if table.find(playersTaken, player) then return end
			if table.find(blacklist, player.UserId) then return end--already in table

			player.leaderstats.Points.Value += points

			points -= 15 --decrease the points by 15 for the next player

			table.insert(playersTaken, player) --add the player to the table so they can't get points again
		end

	humanoid.Died:Connect(onDied)
end

player.CharacterAdded:Connect(onCharacterAdded)

end

Players.PlayerAdded:Connect(onPlayerAdded)
`

1 Like

try this:

local Players = game:GetService("Players")
local points = 60
local playersTaken = {}
local blacklist = {[88851721] = true}

local function onPlayerAdded(player)
	player.CharacterAdded:Connect(function(character)
        local humanoid = character:WaitForChild("Humanoid")
        humanoid.Died:Connect(function()
            if not game.ServerScriptService.activate.Enabled then
                return
            end

            if playersTaken[player] or blacklist[player.UserId] then
                return
            end
    
            player.leaderstats.Points.Value += points
            points -= 15
    
            table.insert(playersTaken, player)
            playersTaken[player] = true
        end)
    end)
end

Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(function(player)
    playersTaken[player] = nil
end)
1 Like

appreciate it brother, it works

2 Likes

glad it works, mark it as solution if you found it helpful!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.