Scripting issue

I have a few scripts that worked on a glitch API system. I wanted to move them over to the Heroku system. When I moved it over it stopped working. Any way I can fix these two scripts?

local http = game:GetService("HttpService")
local MarketplaceService = game:GetService("MarketplaceService")
local WrongAnswersToFail = 3
local PassRank = 6
local url = "Application_URL"
local APIKEY = "API_KEY_HERE"
local groupId = 5344349 


local gamepassid = 0
local discordWebhookurl = ""

function rankUser(UserId, RoleId)
	game:GetService("HttpService"):GetAsync( url.."?user_name="..plr.Name.."&key=".. APIKEY.."&groupid=" ..groupId.."&role_number="..PassRank)
end

local function format(num, digits)
	return string.format("%0" .. digits .. "i", num)
end

local function parseDateTime()
	local osDate = os.date("!*t")
	local year, mon, day = osDate["year"], osDate["month"], osDate["day"]
	local hour, min, sec = osDate["hour"], osDate["min"], osDate["sec"]
	return year .. "-" .. format(mon, 2) .. "-" .. format(day, 2) .. "T" .. format(hour, 2) .. ":" .. format(min, 2) .. ":" .. format(sec, 2) .. "Z"
end

local FinishText = Instance.new("StringValue", game.Lighting)
FinishText.Name = "FinishText"

function passUser(Player)
	game.Lighting.FinishText.Value = "You have passed your application.... please wait while we rank you......."
	rankUser(Player.UserId, PassRank)
	local Data = {
		["embeds"] = {{
			["author"] = {
				["name"] = Player.Name,
				["url"] = "https://www.roblox.com/users/"..tostring(Player.UserId).."/profile",
				["icon_url"] = ""
			},
			["title"] = "Application Log",
			["description"] = Player.Name.." has **passed** their application. They should have been ranked.",
			["footer"] = {
				["text"] = "User ID: " .. tostring(Player.UserId)
			},
			["color"] = 3468099,
			["timestamp"] = parseDateTime()
		}}
	}
	Data = http:JSONEncode(Data)
	--http:PostAsync(discordWebhookurl, Data)
end

function skipUser(Player)
		game.ReplicatedStorage.SkipApplicationEvent:FireClient(Player)
		game.Lighting.FinishText.Value = "You've skipped your application! Ranking you now..."
		rankUser(Player.UserId, PassRank)
		local Data = {
			["embeds"] = {{
				["author"] = {
					["name"] = Player.Name,
					["url"] = "https://www.roblox.com/users/"..tostring(Player.UserId).."/profile",
					["icon_url"] = ""
				},
				["title"] = "Application Log",
				["description"] = Player.Name.." has **skipped** their application.",
				["footer"] = {
					["text"] = "User ID: " .. tostring(Player.UserId)
				},
				["color"] = 13434739,
				["timestamp"] = parseDateTime()
			}}
		}
		Data = http:JSONEncode(Data)
	--http:PostAsync(discordWebhookurl, Data)
end

function skipUser2(Player)
	rankUser(Player.UserId, PassRank)
	local Data = {
		["embeds"] = {{
			["author"] = {
				["name"] = Player.Name,
				["url"] = "https://www.roblox.com/users/"..tostring(Player.UserId).."/profile",
				["icon_url"] = ""
			},
			["title"] = "Application Log",
			["description"] = Player.Name.." has **skipped** their application.",
			["footer"] = {
				["text"] = "User ID: " .. tostring(Player.UserId)
			},
			["color"] = 13434739,
			["timestamp"] = parseDateTime()
		}}
	}
	Data = http:JSONEncode(Data)
	--http:PostAsync(discordWebhookurl, Data)
	wait(3)
	Player:Kick('\nSuccessfully ranked! Please inform an Executive+ if you haven\'t been ranked.')
end

function failUser(Player)
	game.Lighting.FinishText.Value = "You've failed your application. Try again later!"
	local Data = {
		["embeds"] = {{
			["author"] = {
				["name"] = Player.Name,
				["url"] = "https://www.roblox.com/users/"..tostring(Player.UserId).."/profile",
				["icon_url"] = ""
			},
			["title"] = "Application Log",
			["description"] = Player.Name.." has **failed** their application.",
			["footer"] = {
				["text"] = "User ID: " .. tostring(Player.UserId)
			},
			["color"] = 15158605,
			["timestamp"] = parseDateTime()
		}}
	}
	Data = http:JSONEncode(Data)
	--http:PostAsync(discordWebhookurl, Data)
	wait(5)
	Player:Kick("Failed\nYou've failed your application. Try again later!")
end

game.Players.PlayerAdded:Connect(function(Player)
	local Data = {
		["embeds"] = {{
			["author"] = {
				["name"] = Player.Name,
				["url"] = "https://www.roblox.com/users/"..tostring(Player.UserId).."/profile",
				["icon_url"] = "https://www.roblox.com/headshot-thumbnail/image?userId="..tostring(Player.UserId).."&width=420&height=420&format=png"
			},
			["title"] = "Player Joined",
			["description"] = Player.Name.." has **joined** the application center .",
			["footer"] = {
				["text"] = "User ID: " .. tostring(Player.UserId)
			},
			["color"] = 51455,
			["timestamp"] = parseDateTime()
		}}
	}
	Data = http:JSONEncode(Data)
	--http:PostAsync(discordWebhookurl, Data)
end)

game.ReplicatedStorage.Prompt.OnServerEvent:Connect(function(Player,plr)
	MarketplaceService:PromptGamePassPurchase(Player,gamepassid)
	MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassID, purchaseSuccess)
		if purchaseSuccess == true and purchasedPassID == gamepassid then
			skipUser(player)
		end
	end)
	MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassID, purchaseSuccess)
		if purchaseSuccess == false and purchasedPassID == gamepassid then
			game.ReplicatedStorage.Back:FireClient(Player)
		end
	end)

	local hasPass = false

	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamepassid)
	end)	
	if not success then
		warn("Error while checking if player has pass: " .. tostring(message))
		return
	end
	if hasPass == true then
		skipUser(Player)
	end
end)

game.ReplicatedStorage.Prompt2.OnServerEvent:Connect(function(Player,plr)
	MarketplaceService:PromptGamePassPurchase(Player,gamepassid)
	MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassID, purchaseSuccess)
		if purchaseSuccess == true and purchasedPassID == gamepassid then
			game.ReplicatedStorage.PleaseWait:FireClient(Player)
			skipUser2(player)
		end
	end)

	local hasPass = false

	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamepassid)
	end)	
	if not success then
		warn("Error while checking if player has pass: " .. tostring(message))
		return
	end
	if hasPass == true then
		skipUser(Player)
	end
end)

game.ReplicatedStorage.FinishApplicationEvent.OnServerEvent:Connect(function(Player, Questions, UserAnswers)
	local IncorrectAnswers = 0
	
	for i = 1, #Questions do
		local CorrectAnswer = Questions[i][6]
		if CorrectAnswer ~= UserAnswers[i] then
			IncorrectAnswers = IncorrectAnswers + 1
		end
	end
	
	if IncorrectAnswers >= WrongAnswersToFail then
		failUser(Player)
	else
		passUser(Player)
	end
end)

–



local Http = game:GetService("HttpService") 
local DiscordWebhook = ""

local GroupId = 8428801 
local url = "Application_URL"
local APIKEY = "API_KEY_HERE"


local date = os.date("!*t") 


function rankUser(UserId,RoleId) -- Rank user function.
	Http:GetAsync(url.."?user_name="..plr.Name.."&key=".. APIKEY.."&groupid=" ..groupId.."&role_number="..PassRank) -- Ranking them online.
end

game.Players.PlayerAdded:Connect(function(plr)
	
	local Minutes = plr:WaitForChild("leaderstats").Minutes -- Local leaderstat
	
	local Data = { -- Making A Rank Message
		["content"] = plr.Name.." ,was just ranked. | "..date.month.."/"..date.day.."/"..date.year
	}
	
	Data = Http:JSONEncode(Data)
	
	if plr:IsInGroup(GroupId) and plr:GetRankInGroup(GroupId) >= 1 then 
		
		Minutes.Changed:Connect(function()
			local RoleId 
			if Minutes.Value >= 100000 then 
				RoleId=4
				rankUser(plr.UserId,RoleId) 
				Http:PostAsync(DiscordWebhook, Data) 
			elseif Minutes.Value >= 10000 then 
				RoleId=3 
				rankUser(plr.UserId,RoleId)
				Http:PostAsync(DiscordWebhook, Data)
			elseif Minutes.Value >= 5000 then 
				RoleId=2
				rankUser(plr.UserId,RoleId) 
				Http:PostAsync(DiscordWebhook, Data) 
			end
		end)
		
	end
	
end)

No errors in the output,

1 Like

It’s more likely the issue is on heroku, can we see your heroku logs?

Sure, give me one moment.

The request is not even sending to heroku since the only logs I have are from starting the API.

Alright, are we able to get the code?

Hello! I am very confused, because I coded in everything correctly for the !promote and !demote but it still won’t work. I would love to be assisted.

1 Like

Can you make a new scripting support post please?

Code is in the origional post.

Shown here and above

Yep! I will send pictures too.

Could you please make a new post.

@Connor_Burke

(I was in a power outage yesterday, so I couldn’t respond)

No, heroku code please.

(I was in a power outage yesterday, so I couldn’t respond)

Sorry, what Heroku code do ya want?

Well, first off PassRank doesn’t have a value, and change Local GroupId to Local groupId

I scrapped the top script I just use the main ranking app center. The second one still aint workin.



local Http = game:GetService("HttpService")



local DiscordWebhook = "" 

local Group = 5344349 

local date = os.date("!*t") 



game.Players.PlayerAdded:Connect(function(plr)
	
	local Minutes = plr:WaitForChild("leaderstats").Points 
	
	local Data = { 
		["content"] = plr.Name.." ,was just ranked. | "..date.month.."/"..date.day.."/"..date.year
	}
	
	Data = Http:JSONEncode(Data)
	
	if plr:IsInGroup(Group) and plr:GetRankInGroup(Group) >= 1 then 
		Minutes.Changed:Connect(function() 
			local RoleId 
			if Minutes.Value >= 10 then 
				Http:PostAsync("Herokuhere/group/rank?user_name="..plr.Name.."&key=SDOIJSDFAJHLFASLJKJFA.SKFASJK.&groupid=5344349&role_number=12")
				Http:PostAsync(DiscordWebhook, Data) 
			elseif Minutes.Value >= 10000 then 
				Http:PostAsync("herokuhere/group/rank?user_name="..plr.Name.."&key=SDOIJSDFAJHLFASLJKJFA.SKFASJK.&groupid=5344349&role_number=14")
				Http:PostAsync(DiscordWebhook, Data) 
			elseif Minutes.Value >= 5000 then  
				Http:PostAsync("herokuhere/group/rank?user_name="..plr.Name.."&key=SDOIJSDFAJHLFASLJKJFA.SKFASJK.&groupid=5344349&role_number=16")
				Http:PostAsync(DiscordWebhook, Data)
			end
		end)
		
	end
	
end)

Edited - Error is -


The bot ranks when I use any other things but the script

Is it still not working…?

Still not,
The error says Argument 2 missing/