Hi I was wonder if you can check all players points on the leaderboard, then if they have like 5 points the game ends. I am not requesting this, just can you help me?
✓ ANSWER ACCEPTED
Finding everyones points and if they have a certin amount of points game ends?
2 answers
✓ Accepted answer
local highScore = 5 -- limit
-- create a function to return the "score" or value of the passed
-- argument/leaderstats
local function getScore(user, stat)
if user and stat then
-- if no empty parameters, proceed
local stats = user:WaitForChild("leaderstats")
local score = stats:WaitForChild(stat)
if score then
-- return the value of the leaderstat
-- if found
return score.Value
end
end
end
-- game loop
local gameOver = false
while true do
for _, player in next, game.Players:GetPlayers() do
if getScore(player, "KOs") >= highScore then
gameOver = true
end
end
if gameOver then
break
else
warn("game running")
end
end
--
victorypoints = 5
for i,v in pairs(game.Players:GetChildren()) do
if v.leaderstats.Points >= victorypoints then
--GAME OVER CODE
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
try it out