There is errors when i'm trying to click the developer product.
Error: 10:02:24.571 - Players.inpu_ts.PlayerGui.ScreenGui.Frame.TextButton.LocalScript:6: attempt to index local 'purchase' (a nil value)
Script:
local id = 332605014 local players = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() local purchase = game:GetService("MarketplaceService"):PromptProductPurchase(players, id) purchase.players.leaderstats.Money.Value = players.leaderstats.Money.Value + 2 end)
PromptProductPurchase
returns void. You'll have to check if the player purchased it with PromptPurchaseFinished
. You're also awarding things on the client, which is bad because they can reward themselves so much more. This is your new script:local id = 332605014 local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(player, id) end)
ServerScriptService
local MPS = game:GetService("MarketplaceService") MPS.PromptPurchaseFinished:Connect(function(plr,id,bought) -- listens for prompt finish if id == 332605014 and bought then -- if they BOUGHT and not cancelled, and it's the id then plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 2 -- awarding on the server end end)