how can I give something to the player if he/she bought?
local plr = game:GetService("Players").LocalPlayer
local Market = game:GetService("MarketplaceService")
local devProduct = script.Parent.DevProduct
local function buy()
Market:PromptProductPurchase(plr, devProduct.Value)
end
script.Parent.MouseButton1Click:Connect(function() buy() end)
script.Parent.ImageButton.MouseButton1Click:Connect(function() buy() end)
-- \\ Server script //
function GiveItem(RecieptInfo)
local Player = game.Players:GetPlayerByUserId(RecieptInfo.PlayerId)
if not Player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if Player then
print("Player is still in game..")
if RecieptInfo.ProductId == YourProductId then
print("Player has bought a devproduct!")
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end
game:GetService("MarketPlaceService").ProcessReciept = GiveItem
Put this in a completely new script (Server Script)
Oh changed my script, and no need for remote events…? This happens right after a purchase is bought. Use my changed script. Don’t worry about any remote events.