I have a game where you can vote for a player and it will give you their name as a Stringvalue in leaderstats. I need it to change that value to None when the player they voted for leaves. I have a script but it does not work at all.
game.Players.PlayerRemoving:Connect(function(plr)
local Players = game:GetService("Players")
local function getPlayersArray()
local players = {}
for _, p in pairs(Players:GetPlayers()) do
local points = p:FindFirstChild("leaderstats")
print(points)
table.insert(players, {player = p, Points = points})
print(points)
end
return players
end
getPlayersArray()
end)