I made a script which can auto rank you in the group if you have enough points.
The problem is it keeps on promoting
Example: I have a table which makes it so when you get 150 points, you get promoted. But the problem is, it keeps on promoting the user whenever it checks the user’s points. How do I get it to stop promoting once it got promoted once?
local pointValueForPromote = 150
local groupId = 5143432;
local requiredRank = 6;
local server = ‘private url’
local key = ‘oof’
– Configuration Varibles –
– Standard Variables –
local HttpService = game:GetService(‘HttpService’)
local dbService = game:GetService(‘DataStoreService’)
local pointDb = dbService:GetDataStore(“points”)
– Standard Variables –
– Main Code –
while true do
wait(30)
print(‘Starting check…’)
local arr = {}
for i, p in pairs(game.Players:GetPlayers()) do
local data = {
plrName = p.Name,
pointValue = p.leaderstats.Points.Value
}
table.insert(arr, data)
end
for i, v in pairs(arr) do
if(v.pointValue >= pointValueForPromote) then
local plrName = v.plrName
local plrObj = game.Players:FindFirstChild(plrName)
local res
local success, err = pcall(function()
res = HttpService:GetAsync(server…‘promote?user=’…plrName…‘&key=’…key…‘&author=SYSTEM’)
end)
if(err) then
warn("There was an error while trying to connect to the server! Here’s the error message: " … err)
else
plrObj.leaderstats.Points.Value = 0
pointDb:SetAsync(plrObj.UserId … ‘-points’, plrObj.leaderstats.Points.Value)
print("Sent promote request! Here’s the response from the server: " … res)
end
end
end
print(‘Finished check!’)
wait(30)
end