So, i am trying to make a script that, once a player has a gamepass, it would give 50 money every minute.
Here's my script i've got so far..
01 | DataStore = game:GetService( "DataStoreService" ):GetDataStore( "PurchaseHistory" ) |
02 | local plr = game.Players.LocalPlayer |
03 |
04 | game:GetService( "MarketplaceService" ).ProcessReceipt = function (infoo) |
05 | local playerDPkey = infoo.PlayerId.. ":" ..infoo.PurchaseId |
06 | if DataStore:GetAsync(playerDPkey) then |
07 | else |
08 | print (playerDPkey) |
09 | for i,v in pairs (game.Players:GetChildren()) do |
10 | if v.userId = = infoo.PlayerId then |
11 | if infoo.ProductId = = 667369456 then |
12 | plr.leaderstats.Value = plr.leaderstats.Value + 50 -- Gives 50 money |
13 | wait( 70 ) |
14 | repeat |
15 | plr.leaderstats.Value = plr.leaderstats.Value + 50 -- Repeats |
It doesn't add the money to the player.
If you think anything's wrong, let me know with an answer or a comment. Thanks!
You are trying to add value directly to the leaderstats value, which is incorrect.
I don't know the correct name of the value you want to change (whether it's Money, Cash, etc), so I'll just put a string variable for you to change at the top. All you need to do is add one more path into the adding value to make it add to the specific money value.
01 | local nameVal = "Money" -- change the name of this to whatever the actual name of the value is |
02 |
03 | DataStore = game:GetService( "DataStoreService" ):GetDataStore( "PurchaseHistory" ) |
04 | local plr = game.Players.LocalPlayer |
05 |
06 | game:GetService( "MarketplaceService" ).ProcessReceipt = function (infoo) |
07 | local playerDPkey = infoo.PlayerId.. ":" ..infoo.PurchaseId |
08 | if DataStore:GetAsync(playerDPkey) then |
09 | else |
10 | print (playerDPkey) |
11 | for i,v in pairs (game.Players:GetChildren()) do |
12 | if v.userId = = infoo.PlayerId then |
13 | if infoo.ProductId = = 667369456 then |
14 | plr.leaderstats [ nameVal ] .Value = plr.leaderstats [ nameVal ] .Value + 50 |
15 | wait( 70 ) |