API keeps timing out, how can I prevent this?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local groupId = 6413194
local api = require(4690204259)("domain", "key", groupId)
local TeleportService = game:GetService("TeleportService")
local gameID = 5074720976


ReplicatedStorage.Events.Promote.RequestPromotion.OnServerEvent:Connect(function(Player, RankId)
	if Player:GetRankInGroup(groupId) ~= groupId then
		print(api.setRank(Player.UserId, RankId)) -- Change 5
		Player.PlayerGui.RankGUI.Frame.Visible = false
	
			
							end
	
	

end)

^ server script for remote event

script.Parent.MouseButton1Down:Connect(function()

local RankId = 40

game.ReplicatedStorage.Events.Promote.RequestPromotion:FireServer(RankId)

end)

local script that fires remote event ^

I’ve just implemented a new system where people can pick their own orientation for a LGBTQ+ hangout I’ve created. However there seems to be a problem with it crashing due to too many requests at once (my fault for underestimating how many people would come to the grand opening)

If anybody knows how I can prevent this from crashing/timing out? Thanks!

Why not make a queue?

When the client sends the remote, you could then add it to a table. A separate loop/script will send x requests/ min by reading the table up to a certain point. At that point, delete all of the sent requests and then start the process over again.

(This is assuming the request limit is on Roblox’s limitations, and not your api service)

That’s the error I’ve been receiving (my apologies I meant to upload screenshots of the error with this post and must have forgotten)

So the queue idea didn’t work?

Well then I’m not sure at that point. In that case I’d try dissecting out within your module any cases where it can be firing too many requests