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)
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)