Riot system Code Help

Hello, I am currently working on a riot system, going alright so far. I just need a little bit of help with a piece of code.

So I am trying to make it so that when a developer product is purchased that it gives a certain team guns for a certain ammount of time. I already have the developer product code I just don’t know how I would make it so it would only give a certain team a tool for a set time.

1 Like

Developer products need to be handled by the “ProcessReceipt” callback function of the “MarketplaceService”, here’s an example script which you can use to award all players of a particular team a tool when one of their players purchases a product.

Remember that a game can only have a single defined “ProcessReceipt” callback so any other developer products will need to be handled by it as well.

local marketplace = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local server = game:GetService("ServerStorage")
local sword = server.LinkedSword --Example tool in "ServerStorage" folder.

local productId = 0 --Change to ID of developer product.

local function processReceipt(receiptInfo)
	if receiptInfo.ProductId == productId then
		local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
		if player then
			local team = player.Team
			if team then
				for _, teamPlayer in ipairs(team:GetPlayers()) do
					local backpack = teamPlayer.Backpack
					local swordClone = sword:Clone()
					swordClone.Parent = backpack
				end
			end
			return Enum.ProductPurchaseDecision.PurchaseGranted
		else
			return Enum.ProductPurchaseDecision.NotProcessedYet
		end
	end
end

marketplace.ProcessReceipt = processReceipt

https://developer.roblox.com/en-us/api-reference/callback/MarketplaceService/ProcessReceipt