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

Why does this Dev Product script not give "value" when purchased? [closed]

Asked by 3 years ago

This question already has an answer here:

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

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
You just sent a duplicate. Dovydas1118 1495 — 3y
0
try using "local cs" instead of just "cs" CoinWield 47 — 3y

Marked as Duplicate by Dovydas1118, WizyTheNinja, and CreationNation1

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?