How to create Auto Rank Points System by using Glitch

Hey Developer! I’m Abd_Dev, or you can call me Abd.

I just created this tutorial to show you how to make Auto Rank Points script, like when you get 500 Points in-game you get ranked at the Group or you get promoted.

[NOTE] We’ll use the Glitch Hosting Tutorial by @CAP7A1N

Why?

At this moment, I see many people asking about how to make Auto Rank Points and searching about developers that make this kind of things.
So… I decided to make a tutorial about how to make that by using Glitch.com!


Part 1: Hosting

Click here on and follow the Part 1 in CAP7A1N’s Tutorial.


Part 2: Get the Cookie

1. Go to an incognito window.

2. Press F12 / FN + F12 / CTRL + SHIFT + I to access Developer Console

3. Find “Application” on the top bar.

4. Open “Cookies” and press “roblox. com”

5. Find “.ROBLOSECURITY”

6. Double Click the Value section of “.ROBLOSECURITY”

7. Copy it using CTRL + C

8. Go back to Glitch .com at Config.js/user_cookie!

9. Continue to the next Part.


Part 3: LUA

Go back to CAP7A1N’s Tutorial and follow the Part 2 from the Tutorial.


Part 4: Roblox Scripts

1. Enable HTTP Service in the Game Settings.
image


2. Put the Script below in the Main script in ServerScriptService.

Script
local HttpService = game:GetService("HttpService")
local Server = require(script.Server)

--/ Settings

local Settings = {
	["GroupID"] = 00000, -- Group ID here
	["RanksToRank"] = {
		["RankName"] = "NAME HERE",
		["RankName1"] = "NAME HERE" -- Copy if you need more.
	}
}

--/ Leaderstats

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("PointsStats")
 
game.Players.PlayerAdded:Connect(function(Player)
    local Leaderstats = Instance.new("Folder", Player)
    Leaderstats.Name = "leaderstats"
    local POINTS = Instance.new("IntValue", Leaderstats)
    POINTS.Name = "Points"
    POINTS.Value = 0
 
    local Data = DataStore:GetAsync(Player.UserId)
	if Data then
		POINTS.Value = Data
	else
		POINTS.Value = 20 -- Change the 20 to whatever you want the points to be when the player first joins the game.
	end
	 POINTS.Changed:Connect(function()
		if Player.leaderstats.Points.Value >= 0 then -- Change the 0 to the value of the points that you want the player to get to get ranked.
			Server.SetRank(Settings.GroupID, Player.UserId, 0) -- Change the 0 to the rank id of the rank that you want the player to get ranked to.
			
		elseif Player.leaderstats.Points.Value >= 0 then -- Change the 0 to the value of the points that you want the player to get to get ranked.
			Server.SetRank(Settings.GroupID, Player.UserId, 0) -- Change the 0 to the rank id of the rank that you want the player to get ranked to.
			
		--elseif plr.leaderstats.Points.Value >= 0 then -- Change the 0 to the value of the points that you want the player to get to get ranked.
			--Server.SetRank(Settings.GroupID, plr.UserId, 0) -- Change the 0 to the rank id of the rank that you want the player to get ranked to.
		end
	end)
end)
 
game.Players.PlayerRemoving:Connect(function(Player)
	local success, f = pcall(function()
		DataStore:SetAsync(Player.UserId, Player.leaderstats.Points.Value)
	end)
	
	if not success then
		local count = 1
		repeat
			warn("[POINTS RANKING]: Error- saving " .. Player.Name .. "'s data failed.\nAttempt: " .. tostring(count) .. "\nError Message: " .. f)
			success, f = pcall(function()
                                count += 1
				DataStore:SetAsync(Player.UserId, Player.leaderstats.Points.Value)
			end)
			wait(5)
		until success or count >= 5
	end
end)

THANKS FOR READING

Hope you like the tutorial, I thank @CAP7A1N for his helpful Glitch tutorial and @oxazolone for helping me while making the tutorial.

Have a nice day. :smile:

5 Likes

Very nice tutorial, abd. I would love to see more of your posts because they’re very helpful!

1 Like

Thanks for the feedback, it really means too much to me.

Nice tutorial, but IMO you should go more in depth about how you are doing it, since for those who don’t script maybe want to learn or non-advanced users looking for new things to learn. It’d help greatly to get an explanation on everything you do in your script.

1 Like

Okay, Thanks for the feedback! I’ll try to do that and edit it soon.

1 Like

I notices a few things about your final script…
The datastore had no pcall and the rank would only update when the player resets.

I have edited your script, and changed it so that when the points value is changed the script checks if the points are high enough for a promotion and then, if they have enough, it will rank them accordingly.

I also added a pcall and a check to your save function.

New Script:
local HttpService = game:GetService("HttpService")
local Server = require(script.Server)

--/ Settings

local Settings = {
	["GroupID"] = 00000, -- Group ID here
	["RanksToRank"] = {
		["RankName"] = "NAME HERE",
		["RankName1"] = "NAME HERE" -- Copy if you need more.
	}
}

--/ Leaderstats

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("PointsStats")
 
game.Players.PlayerAdded:Connect(function(Player)
    local Leaderstats = Instance.new("Folder", Player)
    Leaderstats.Name = "leaderstats"
    local POINTS = Instance.new("IntValue", Leaderstats)
    POINTS.Name = "Points"
    POINTS.Value = 0
 
    local Data = DataStore:GetAsync(Player.UserId)
	if Data then
		POINTS.Value = Data
	else
		POINTS.Value = 20 -- Change the 20 to whatever you want the points to be when the player first joins the game.
	end
	 POINTS.Changed:Connect(function()
		if Player.leaderstats.Points.Value >= 0 then -- Change the 0 to the value of the points that you want the player to get to get ranked.
			Server.SetRank(Settings.GroupID, Player.UserId, 0) -- Change the 0 to the rank id of the rank that you want the player to get ranked to.
			
		elseif Player.leaderstats.Points.Value >= 0 then -- Change the 0 to the value of the points that you want the player to get to get ranked.
			Server.SetRank(Settings.GroupID, Player.UserId, 0) -- Change the 0 to the rank id of the rank that you want the player to get ranked to.
			
		--elseif plr.leaderstats.Points.Value >= 0 then -- Change the 0 to the value of the points that you want the player to get to get ranked.
			--Server.SetRank(Settings.GroupID, plr.UserId, 0) -- Change the 0 to the rank id of the rank that you want the player to get ranked to.
		end
	end)
end)
 
game.Players.PlayerRemoving:Connect(function(Player)
	local success, f = pcall(function()
		DataStore:SetAsync(Player.UserId, Player.leaderstats.Points.Value)
	end)
	
	if not success then
		local count = 1
		repeat
			warn("[POINTS RANKING]: Error- saving " .. Player.Name .. "'s data failed.\nAttempt: " .. tostring(count) .. "\nError Message: " .. f)
			success, f = pcall(function()
				DataStore:SetAsync(Player.UserId, Player.leaderstats.Points.Value)
			end)
			wait(5)
		until success or count >= 5
	end
end)
1 Like

For Part 4, all you do is give people a script without explaining what to do with it and how it works.

1 Like

Just to point out, glitch isn’t the best at security as lots of users has had a bad experience with it, but it still works the way intended, just make sure you secure your projects

2 Likes

Glad you could build off of my tutorial. Although, you should consider switching this to DataStore2 as it is much more reliable.

1 Like

This does not work as expected. You are never increasing a count after you attempt it. Here is the fixed script:

game.Players.PlayerRemoving:Connect(function(Player)
	local success, f = pcall(function()
		DataStore:SetAsync(Player.UserId, Player.leaderstats.Points.Value)
	end)
	
	if not success then
		local count = 1
		repeat
			warn("[POINTS RANKING]: Error- saving " .. Player.Name .. "'s data failed.\nAttempt: " .. tostring(count) .. "\nError Message: " .. f)
			success, f = pcall(function()
                                count += 1
				DataStore:SetAsync(Player.UserId, Player.leaderstats.Points.Value)
			end)
			wait(5)
		until success or count >= 5
	end
end)
1 Like