#How to get players scores from LeaderStats and see who has the lowest point to kill them off?
8 messages · Page 1 of 1 (latest)
Basically It gets the players in leaderstats and checks a player leaderstats value. The player with lowest value
will be killed
for loop
I've tried making this but isn't working
local Part = script.Parent
Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr.leaderstats.coins.Value < plr.leaderstats.coin.value then
hit.Parent.Humanoid.Health = 0
end
end
end)```
function getLowestStatPlayer(statName)
local current = math.huge
local player = nil
for _, Player in Players:GetPlayers() do
local stat = player.leaderstats[statName]
if stat.Value < current then
current = stat.Value
player = Player
end
end
return player
end