I am trying to make it so when the player touches the part, it prompts the developer product they can buy, and then a speed coil will go into the players starterpack. The prompt worked but the speed coil did not go into the players starterpack.
Code in server script service:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local speedCoil = game:GetService("ServerStorage").SpeedCoil
local Players = game:GetService("Players")
local boughtTimes = 0
local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")
local productFunctions = {}
productFunctions[1780413266] = function(receipt, player)
local starterPack = game:GetService("StarterPack")
if starterPack then
local clonedSpeedCoil = speedCoil:Clone()
clonedSpeedCoil.Parent = starterPack
return true
end
end
Script under the part
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local touchPart = script.Parent
local productId = 1780413266
touchPart.Touched:Connect(function(otherPart)
local player = Players:GetPlayerFromCharacter(otherPart.Parent)
if player then
MarketplaceService:PromptProductPurchase(player, productId)
end
end)