I used Roblox AI Assistant to script a simple purchase prompt for when a player meets a specific requirement on their leaderstats. I’ve tested this various different times & still havent managed to get it to work. I would love some help! (script resides in ServerScriptService btw)
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local YENS_REQUIREMENT = 100 -- Change this to your desired requirement
local function promptPurchase(player)
local yens = player.leaderstats.Yens.Value
if yens >= YENS_REQUIREMENT then
local productId = 123456789 -- Replace with the UGC product ID
MarketplaceService:PromptPurchase(player, productId)
end
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(function(character)
promptPurchase(player)
end)
end
Players.PlayerAdded:Connect(onPlayerAdded)