local ITEM_ID = 15761722167
local GROUP_ID = 33454444
local MarketplaceService = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer
local l1 = plr:WaitForChild("leaderstats")
local v1 = l1:WaitForChild("rebirths")
local l2 = plr:WaitForChild("leaderstats")
local v2 = l1:WaitForChild("strength")
local l3 = plr:WaitForChild("leaderstats")
local v3 = l1:WaitForChild("coins")
script.Parent.MouseButton1Click:Connect(function()
if plr:IsInGroup(GROUP_ID) and v1.Value >= 2 and v2.Value >= 10000 and v3.Value >= 20 then
local success, doesPlayerOwnItem = pcall(MarketplaceService.PlayerOwnsAsset, MarketplaceService, plr, ITEM_ID)
if success and not doesPlayerOwnItem then
MarketplaceService:PromptPurchase(plr, ITEM_ID)
else
end
else
end
end)
PromptPurchase (or any other purchases) must be made by a Server Script, not a Local Script. Use a RemoteEvent to send the Item Id to the Server
-- Create A remoteEvent
local RemoteEvent = --path to RemoteEvent
script.Parent.MouseButton1Click:Connect(function()
if plr:IsInGroup(GROUP_ID) and v1.Value >= 2 and v2.Value >= 10000 and v3.Value >= 20 then
local success, doesPlayerOwnItem = pcall(MarketplaceService.PlayerOwnsAsset, MarketplaceService, plr, ITEM_ID)
if success and not doesPlayerOwnItem then
RemoteEvent:FireServer(ITEM_ID)
else
end
else
end
end)
Server Script:
local RemoteEvent = -- Path To RemoteEvent
local MarketplaceService= game:GetService("MarketplaceService")
RemoteEvent.OnServerEvent:Connect(function(player, ITEM_ID)
MarketplaceService:PromptPurchase(player, ITEM_ID)
end)