So, I have a screenGui that when clicked gives the PromptProductPurchase
and brings up a 5 robux dev product that is SUPPOSE to give you +10 walkspeed for one life and it also stacks. So far, all it does is drain money. One script is placed with in the ScreenGui (NOT the textbutton) and the other is placed in Workspace. Also, NOTHING has come up in the output accept: "Place has to be opened with Edit button to access DataStores" but it is already in Edit mode.
Here is the script placed in Workspace. The point of this script is to find the receipt and find the product the and player who purchased it, then award the extra walkspeed (10)
local developerProduct = "http://www.roblox.com/Item-Link-item?id=20338463" -- Item link to the developer product, you must use the WHOLE Link, not just the ID. local speedInc = 10 --Change this to the amount of Walkspeed you'd like to give. Stack = true --If you set this to true, the user will get the effect of there normal Walkspeed & will get an add on of the Set Amount. i.e; If you have 16 Walkspeed, and you set it to true, whatever amount will become 26+66=92 total Walkspeed. function getItemId(developerProduct) if tonumber(developerProduct) then return tonumber(developerProduct) elseif developerProduct:find("id=") then a,b = developerProduct:find("id=") return tonumber(developerProduct:sub(b+1)) end end devId = getItemId(developerProduct) function purchaseCompleted(playerId, productId, purchased) if not purchased or productId ~= devId then return false end for i,v in pairs(game.Players:GetPlayers()) do if v.userId == playerId then v.CharacterAdded:connect(function() repeat wait() until v.Character and v.Character:FindFirstChild("Humanoid") v.Character.Humanoid.WalkSpeed = v.Character.Humanoid.WalkSpeed + speedInc end) if v.Character and v.Character:FindFirstChild("Humanoid") then v.Character.Humanoid.WalkSpeed = v.Character.Humanoid.WalkSpeed + speedInc end end end end
Here is the script that is placed inside of the ScreenGui, again, NOT in the TextButton.
local marketplaceService = game:GetService("MarketplaceService") local developerProduct = "http://www.roblox.com/Item-Link-item?id=20338463" -- Item link to the developer product, you must use the WHOLE Link, not just the ID. local walkspeedButton = script.Parent.BuyWalkspeed local player = script.Parent.Parent.Parent function getItemId(developerProduct) if tonumber(developerProduct) then return tonumber(developerProduct) elseif developerProduct:find("id=") then a,b = developerProduct:find("id=") return tonumber(developerProduct:sub(b+1)) end end devId = getItemId(developerProduct) function buyDevProduct() marketplaceService:PromptProductPurchase(player, devId) end walkspeedButton.MouseButton1Down:connect(buyDevProduct)
Thanks for the help!
Script in Workspace:
local developerProduct = 20338463 -- Id of the developer product local speedInc = 10 --Change this to the amount of Walkspeed you'd like to give. Game:GetService("MarketplaceService").ProcessReceipt = function(receipt) if receipt.ProductId == developerProduct then -- the speed dev product for i,v in pairs(game.Players:GetPlayers()) do -- loop through the players if v.userId == receipt.PlayerId then -- if they're the player that bought it if v.Character and v.Character:FindFirstChild("Humanoid") then v.Character.Humanoid.WalkSpeed = v.Character.Humanoid.WalkSpeed + speedInc -- add speedinc to their current walkspeed end end end end end
Put this in a LocalScript inside the TextButton
-- Put this in the TextButton (LocalScript) local marketplace = Game:GetService("MarketplaceService") local developerProduct = 20338463 -- id of the developer product local player = game.Players.LocalPlayer script.Parent.MouseButton1Down:connect(function() marketplace:PromptProductPurchase(player, developerProduct) -- prompt the purchase end)