Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why does this Dev Product script not give value when purchased?

Asked by 3 years ago
Edited 3 years ago

Hey, there!

Thank you for wasting your time out of your day and clicking onto this to maybe help me with this script.

What I'm trying to make is a Dev Product that will give the user (when purchased the product) some leaderstat "strength". My stats handler is located in ServerScriptService, and then there is a folder "plr" with all the intValues in it, such as Strength, etc.

The problem is though, that I cannot get the script below to work.

I also do have another script which connects this with a TextButton in order to prompt the purchase to the user. (Which works as it prompts the user, just doesn't give the user 5 Strength when the user purchases the Dev Product).

Would anyone know why it doesn't give the user 5 Strength in their stats when purchased the Dev Product?

Thank you so much for reading and I will appreciate any help anyone is willing to give!

Script:


local MarketplaceService = game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") CASHID = 1135295617 MarketplaceService.ProcessReceipt = function(receiptInfo) local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId local numberBought = ds:IncrementAsync(playerProductKey, 1) for i,v in pairs (game.Players:GetChildren()) do if v.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == CASHID then lds = v:FindFirstChild("plr") if lds ~= nil then cs = lds:FindFirstChild("Strength") if cs ~= nil then cs.Value = cs.Value + 5 end end end end end return Enum.ProductPurchaseDecision.PurchaseGranted end
0
Either the "plr" folder or the "strength" value is missing. Also, try this for getting the player "local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)." 9mze 193 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

The script you have given is quite unorganized and needs polishing.

Please refer to this video created by the Developer Forum Champion, AlvinBlox for help. Alternatively, watch this video.

Good Luck!

0
Both links are "The item you requested does not exist.". SonGohan6 85 — 3y
Ad

Answer this question