local players = game:GetService("Players")
local function checkPlayerStats(statName, lowerThreshold, upperThreshold)
local foundPlayers = {}
for _, player in ipairs(players:GetPlayers()) do
if player.leaderstats[statName].Value >= lowerThreshold and player.leaderstats[statName].Value <= upperThreshold then
table.insert(foundPlayers, player)
end
end
return foundPlayers
end
for _, v in pairs(game:GetService("Players"):GetChildren()) do
local points = v:FindFirstChild("Points",true)
if points and points.Value >= 100 and points.Value <= 200 then
-- your code here
end
end
It is suitable for the way with more logical differences in each stage
local scoreDatas = {
{
score={0,100},
runFunction = function()
print("score0-100")
end
},
{
score={101,200},
runFunction = function()
print("score101-200")
end
},
}
local playerScore = 100
for _, scoreData in pairs(scoreDatas) do
if playerScore >= scoreData.score[1] and playerScore <= scoreData.score[2] then
scoreData.runFunction()
end
end