Issue with DevProduct Rewards

In my game, the player is able to purchase in-game currency through DevProducts. After making a script to do so it doesn’t give the player the rewards they purchase, in this case, Money, they are prompted with the ability to purchase the DevProduct, but after buying it nothing is given. In the video, I purchased the +1000 Money DevProduct but as you can see I didn’t receive anything.

robloxapp-20200801-1355340.wmv (1.0 MB)

Here is the script:

I have looked for solutions on the DevForum but none seem to work, I have also tried to follow several tutorials although none of them seem to work either.

1 Like

AddToItem = AddToItem + 1000
is the issue here.

AddToItem is a pointer. All your code does is add 1000 to this variable. To change the amount of money the player has, you need to reference the specific Instance you are changing again.

Change that line to
game.Players.LocalPlayer.leaderstats[CurrencyName].Value += 1000

You can remove the variable AddToItem completely.

I implemented this, although it can not identify “leaderstats” which is the Parent for the IntValue “Money” which is what I am trying to add to. I have tried both;

Line 6 ~ local CurrencyName = “Money”
Line 20 ~ game.Players.LocalPlayer.leaderstats[CurrencyName].Value += 1000

and

(No variable)
Line 20 ~ game.Players.LocalPlayer.leaderstats[“Money”].Value += 1000

This image has the output error in which only occurs when the Player is prompted to purchase the Product and presses “Buy Now”. Nothing is given still, I believe it is because of this problem.

Here is an Image of the script after its changes.

You’re using game.Players.LocalPlayer in a server script, only local scripts can use that.

Try
player.leaderstats["Money"].Value += 1000

You already created the variable player which points to the client trying to complete the purchase.

Yep that worked just fine, Thanks for the help!

1 Like