I can't figure out a way to incorporate a spinner that you can buy with Robux? I've tried using remote functions to check if the player bought the Dev Product, it gives you the item, but doesn't show the spinner? Any ideas how I can fix this

System In ServerScriptService

event.OnServerInvoke = function(player, TS ,id)
	
	
	local MarketplaceService = game:GetService("MarketplaceService")
	
	MarketplaceService.ProcessReceipt = function(receiptInfo)
		
		
		local ID = id
		
		local productId = receiptInfo.ProductId
		local playerId = receiptInfo.PlayerId
		local player = getPlayerFromId(playerId)
		local productName
		
		if productId == ID then
			
			
			local returned = module.PurchaseWeapon(player, "Weapon")
			warn(returned)
			return returned
			
		end
	
	end
	
end

Purchase Script In ServerScriptService

function module.PurchaseWeapon(player, crate)
	
	-- << SERVICES >>
	
	local rs = game:GetService("ReplicatedStorage")
	
	
	
	-- << VARIABLES >>
	local contentsModule = rs:WaitForChild("SpinnerContents")
	local contents = require(contentsModule)
	local rfunction = contentsModule.RemoteFunction
	local chanceDepth = 100000000
	local itemTypesHAT1 = contents:GetHatCase1Types()
	local hatsOpened = {}
	
	local CrateS = { -- Table of all the shop items
	
	Weapon = {
	
		Name = "Weapon",
	
		Permisson = contents:PermissionToSpinGP(player),
	
		TypeCrate = contents:GetWeaponCaseTypes()
		
	},
	
}	

warn(crate)

	if crate == CrateS[crate].Name then -- Pet Crate
		warn("OOO")
	
	--[[if not CrateS[crate].Permisson then
		return false
	else]]--
		
		--Eliminate already-owned items
		local modifiedItemTypes = CrateS[crate].TypeCrate
		if contents.EliminateOwnedItems then
			--Get table of currently owned items
			local ownedItems = {}
			for i,v in pairs(player.Inventory.Hats:GetChildren()) do
				ownedItems[v.Name] = true
			end
			--Iterate through each group
			for groupIndex, group in pairs(modifiedItemTypes) do
				local totalItems = #group.Items
				local totalItemsPlusOne = totalItems + 1
				-- Iterate though Items back-to-front so the items remain in the same position if one is removed
				for i = 1, totalItems do
					local itemIndex = totalItemsPlusOne - i
					local item = group.Items[itemIndex]
					if ownedItems[item.Name] or item.Crate ~= crate then
						table.remove(group.Items, itemIndex)
					end
				end
			end
		end
		
		--Generate Items
		local items = {}
		for i = 1, contents.Crates do
			--Determine rarity
			local cumulativeChance = 0
			local rarityGroup
			local randomChance = math.random(1,chanceDepth)/chanceDepth
			for groupIndex, group in pairs(modifiedItemTypes) do
				local chance = group.Rarity.Chance
				cumulativeChance = cumulativeChance + chance
				if randomChance <= cumulativeChance and #group.Items > 0 then
					rarityGroup = group
					break
				end
			end
			
			--If user has collected all items, return error message
			if not rarityGroup then
				return nil, contents.Messages.ServerErrorComplete
			end
			
			--Select random item from rarity group and add to 'items' table
			local newItemsGroup = rarityGroup.Items
			local newItemPos = math.random(1,#newItemsGroup)
			local newItem = newItemsGroup[newItemPos]
			table.insert(items, newItem)
		end
		
		--Deduct price
		local MC = player.MainCurrency
		local stat = MC.Gems
		stat.Value = stat.Value - contents.Price1
		
		--Generate Crate Details and Winning Item
		local winningCrateId = contents.Crates - 5
		local winningItem = items[winningCrateId]
		
		local Folder = player:WaitForChild("Inventory")
		
		warn("OOO")
		
		--Check if duplicate, if not, reward item
		local duplicate = false
		if contents.DuplicateReward and player.Inventory.Hats:FindFirstChild(winningItem.Name) then
			duplicate = true
			player.MainCurrency.Gems.Value = player.MainCurrency.Gems.Value + itemTypesHAT1[winningItem.GroupIndex].Rarity.DuplicateReward
		else

			warn("OOO")
			
			local test = Instance.new("BoolValue",player)
			test.Name = winningItem.Name
			
		end
		--Returns spin details
		return {
			["Items"] = items;
			["WinningCrateId"] = winningCrateId;
			["WinningItem"] = winningItem;
			["Duplicate"] = duplicate;		
		}
		
		end
	
	--end
	
	return hatsOpened
end

Local Script That Activates The Spinner


spin.MouseButton1Down:Connect(function()
	local MarketplaceService = game:GetService("MarketplaceService")
	
	warn("A")
	
	local Players = game:GetService("Players")
	
	local MarketplaceService = game:GetService("MarketplaceService")
	
	local PlayerOwnsAsset = MarketplaceService.PlayerOwnsAsset
	
	local id = 985025707
	
	local Players = game:GetService("Players")
	
	local MarketplaceService = game:GetService("MarketplaceService")
	
	MarketplaceService:PromptProductPurchase(player, id)
	
	local ToSend = "Weapon"
	
	warn("Sent")

	local spinDetails, errorMessage = game.ReplicatedStorage.CheckIfOwns:InvokeServer(ToSend, id)
	
	while wait(1) do
	
	if not spinDetails then
		warn("Error")
		warn(errorMessage)
		
	else
		warn("Spinning")

		SpinFunction(spinDetails)
		
		break
	end
	end
end)

What am I doing wrong here? No errors either, except for the "errormessage"

1 comment

0

??