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!
