Need help with checking points system

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

The ranking is made by lengo

1 Like

Does it not already check the amount of points?

if player.leaderstats.points.Value < 200 then
	button.Text = 'Error: Not enough points!'
end
if points >= 200 then
	local res = HttpService:GetAsync(server..'setrank?user='..plr..'&rank='..'11'..'&key='..key..'&author='..plr.Name)
end

I made that since it did not show a error if not enough points.

you need to be more specific about what your issue is. Here you say that it is that you do not know how to check the amount of poins.

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:

The issue is that I am getting no output when I would execute the code

Try printing the amount of coins

Edit: also change the

function module:checkRank(plr)

To

function module.checkRank(plr)

So I found this error

Players.RAMMgamming.PlayerGui.ScreenGui.TextButton.LocalScript.Functions:4: attempt to index nil with 'leaderstats'

did you change the : to a . ? like i showed in the reply above

Yes, 30 Characters …

Do the player have a leaderstats in it? in a game check if there is a leaderstats in the player

If that does not work try printing player.Name to see if the player exist

Leaderstats are stored in the players folder and the player does have leaderstats

did you print player.Name ?

30 chars

Yes and the player existed

30 chars

Do this and send the output

for _, v  in pairs(player:GetChildren()) do
 print(v.Name)
end
end:1: attempt to index nil with 'GetChildren'

That means that player is nil, and that print(player.Name) should have errored

I messed up the first time here is the right output

RAMMgamming

No, don’t use “game.Players” use the player that comes from the function