I made a check points system that checks a players leaderstats, if they have enough points they get promoted automatically. My issue is that I can’t figure out how to make the button that you press check the amount of points, here is are my scripts:
Button Script:
local module = require(script.Functions)
local button = script.Parent.Parent.TextButton
button.MouseButton1Click:Connect(function(player)
button.Text = 'Checking Rank.'
wait(0.5)
button.Text = 'Checking Rank..'
wait(0.5)
button.Text = 'Checking Rank...'
module.checkRank(player)
if player.leaderstats.points.Value < 200 then
button.Text = 'Error: Not enough points!'
end
end)
Point Checker:
local module = {}
function module:checkRank(plr)
local points = plr.leaderstats.points.Value
local HttpService = game:GetService("HttpService")
local rank = ''
local server = 'server'
local key = 'key'
if plr:GetRankinGroup(4596247) == 6 then
if points >= 200 then
local res = HttpService:GetAsync(server..'setrank?user='..plr..'&rank='..'11'..'&key='..key..'&author='..plr.Name)
end
elseif plr:GetRankInGroup(4596247) == 7 then
if points >= 200 then
local res = HttpService:GetAsync(server..'setrank?user='..plr..'&rank='..'10'..'&key='..key..'&author='..plr.Name)
end
elseif plr:GetRankInGroup(4596247) == 8 then
if points >= 200 then
local res = HttpService:GetAsync(server..'setrank?user='..plr..'&rank='..'9'..'&key='..key..'&author='..plr.Name)
end
end
end
return module