of     1   

beastyfootballtim
#140847435Saturday, July 19, 2014 3:15 PM GMT

The problem with this script, is that it gives you 5 swords before you make the purchase, and another 5 when you do. I want it so when you buy it, it gives you a sword, but when you die/respawn, you have to buy it again. -- setup local variables local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local productId = 20550096 tool = game.Lighting:findFirstChild("Sword") -- define function that will be called when purchase finished MarketplaceService.ProcessReceipt = function(receiptInfo) -- find the player based on the PlayerId in receiptInfo for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then -- check which product was purchased if receiptInfo.ProductId == productId then -- handle purchase: In this case, we are giving the player a sword. game.Lighting.Sword:clone().Parent = player.Backpack game.Lighting.Sword:clone().Parent = player.StarterGear end end -- record the transaction in a Data Store local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId ds:IncrementAsync(playerProductKey, 1) -- tell ROBLOX that we have successfully handled the transaction return Enum.ProductPurchaseDecision.PurchaseGranted end end
ScottRhode
#140847783Saturday, July 19, 2014 3:21 PM GMT

modified the needed section. -- handle purchase: In this case, we are giving the player a sword. if player.BackPack:FindFirstChild("Sword") == nil then game.Lighting.Sword:clone().Parent = player.Backpack end end end
beastyfootballtim
#140848778Saturday, July 19, 2014 3:38 PM GMT

It still gives me a sword before I make the purchase, and doesn't give me a sword after I do.
beastyfootballtim
#140848834Saturday, July 19, 2014 3:39 PM GMT

Output says "Key name is too long"
beastyfootballtim
#140850307Saturday, July 19, 2014 4:00 PM GMT

Bump
santaLover18
#140855414Saturday, July 19, 2014 5:08 PM GMT

Could I have a copy when it works?

    of     1