RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Create a random price item script using Bedwars scripting docs"
-- server script local MarketplaceService = game:GetService("MarketplaceService") local itemId = math.random(1, 100) -- Assumes item IDs are between 1 and 100 local itemPrice = math.random(10, 50) -- Assumes item prices are between 10 and 50 MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, isPurchased) if isPurchased and assetId == itemId then local leaderstats = player:FindFirstChild("leaderstats") if leaderstats then local coins = leaderstats:FindFirstChild("Coins") if coins then coins.Value = coins.Value - itemPrice -- Decrease coins by the price of the item end end end end) local function onButton1Click(player) MarketplaceService:PromptPurchase(player, itemId) end game.ReplicatedStorage.BuyItem.OnServerEvent:Connect(onButton1Click)