Why would this Devproduct script work in Studio, but not in Play?
So, this is a devproduct script, located in the ServerScriptService. The accompanying Shop GUI is in the Starter GUI. When I test it in studio, and click the GUI, I recive the money from paying in robux. However, when I purchase more than once, the amount of game dollars I get is more than when I bought for in robux. I'm not exactly sure why. Also, my main problem is that in Play, I get no ingame cash from purchasing with robux. I've seen similar posts about this and maybe it has to do with the script not being local? I'm not sure, maybe it's something in the script itself. If you could help let me know. Here's the script, Thank you!
01 | game.StarterGui.ResetPlayerGuiOnSpawn = false |
03 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
05 | function getPlayerFromId(id) |
06 | for i,v in pairs (game.Players:GetChildren()) do |
07 | if v.userId = = id then |
14 | MarketplaceService.ProcessReceipt = function (receiptInfo) |
15 | local productId = receiptInfo.ProductId |
16 | local playerId = receiptInfo.PlayerId |
17 | local player = getPlayerFromId(playerId) |
19 | if productId = = 35803838 then |
20 | productName = "$5,000" |
21 | local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) |
23 | cashmoney.Value = cashmoney.Value + 5000 |
25 | elseif productId = = 35803911 then |
26 | productName = "$25,000!" |
27 | local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) |
29 | cashmoney.Value = cashmoney.Value + 25000 |
31 | elseif productId = = 32804673 then |
32 | productName = "$100,000!" |
33 | local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) |
35 | cashmoney.Value = cashmoney.Value + 100000 |
37 | elseif productId = = 35803946 then |
38 | productName = "$1,00,000!" |
39 | local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) |
41 | cashmoney.Value = cashmoney.Value + 1000000 |
43 | elseif productId = = 32804689 then |
44 | productName = "$1,000,000!" |
45 | local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) |
47 | cashmoney.Value = cashmoney.Value + 1000000 |
49 | elseif productId = = 35803720 then |
50 | productName = "+15 Walkspeed" |
51 | local char = player.Character |
53 | local human = char:FindFirstChild( "Humanoid" ) |
55 | human.WalkSpeed = human.WalkSpeed + 15 |
58 | elseif productId = = 35803755 then |
59 | productName = "Turret" |
60 | game.Lighting.SentryTurret:Clone().Parent = player.Backpack |
62 | game.BadgeService:AwardBadge( 0 ) |
63 | local message = Instance.new( "Hint" ,workspace) |
64 | message.Text = player.Name.. " purchased " ..productName.. "!" |
65 | coroutine.resume(coroutine.create( function () |
70 | return Enum.ProductPurchaseDecision.PurchaseGranted |