Alright. So I was Hired to make a UI but KEEP the scripts he made. So I remade the UI. How ever now I’m trying to figure out how his scripts even worked. I’m not GREAT at scripting so that might be the Issue. So this is the Script he had in the frame full other frames that all have the Button named “Buy”
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("Frame") then
v.Buy.MouseButton1Click:Connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(game:GetService("Players").LocalPlayer, v.Id.Value)
end)
end
end
And here is the Script he has in ServerScriptService
local MPS = game:GetService("MarketplaceService")
MPS.PromptProductPurchaseFinished:Connect(function(userID, id, ispurchased)
if ispurchased == true and id == 1528438686 then -- 50 mil
local player = game.Players:GetPlayerByUserId(userID)
player:WaitForChild("Robux").Value = player:WaitForChild("Robux").Value + 50000000
end
if ispurchased == true and id == 1528439226 then -- 100 mil
local player = game.Players:GetPlayerByUserId(userID)
player:WaitForChild("Robux").Value = player:WaitForChild("Robux").Value + 10000000000000000000000000000000000000
end
if ispurchased == true and id == 1528439499 then -- 350M mil
local player = game.Players:GetPlayerByUserId(userID)
player:WaitForChild("Robux").Value = player:WaitForChild("Robux").Value + 350000000
end
if ispurchased == true and id == 1528440163 then -- 1 bil
local player = game.Players:GetPlayerByUserId(userID)
player:WaitForChild("Robux").Value = player:WaitForChild("Robux").Value + 1000000000
end
end)
So how do I designate which buy button does what? Like how do I add a Value to it the the game knows which Devproduct to prompt when I hit buy?
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("Frame") then
v.Buy.MouseButton1Click:Connect(function()
game:GetService("MarketplaceService"):PromptProductPurchase(game:GetService("Players").LocalPlayer, v.Id.Value)
end)
end
end
There was a value of some kind, likely a NumberValue, likely with the gamepass or gamestore information included. Try to find that from before you redid the UI. The value items were named “Id”
EDIT: I need to read full posts next time. So the below script shows everything
local MPS = game:GetService("MarketplaceService")
MPS.PromptProductPurchaseFinished:Connect(function(userID, id, ispurchased)
if ispurchased == true and id == 1528438686 then -- 50 mil
local player = game.Players:GetPlayerByUserId(userID)
player:WaitForChild("Robux").Value = player:WaitForChild("Robux").Value + 50000000
end
if ispurchased == true and id == 1528439226 then -- 100 mil
local player = game.Players:GetPlayerByUserId(userID)
player:WaitForChild("Robux").Value = player:WaitForChild("Robux").Value + 10000000000000000000000000000000000000
end
if ispurchased == true and id == 1528439499 then -- 350M mil
local player = game.Players:GetPlayerByUserId(userID)
player:WaitForChild("Robux").Value = player:WaitForChild("Robux").Value + 350000000
end
if ispurchased == true and id == 1528440163 then -- 1 bil
local player = game.Players:GetPlayerByUserId(userID)
player:WaitForChild("Robux").Value = player:WaitForChild("Robux").Value + 1000000000
end
end)
Just be sure to create new values under each frame of the store options for the very first code block named Id with each gamepass id matching the frame it’s under.