Hello! I want to make developer products for my game that gives a player cash depending on multiple stats that he has. I made a script for the developer products and it works fine, so now I want to make that the cash that the player receives changes depending on another stat that he has.
My idea is to create a NumberValue in ReplicatedStorage, this value gets updated by a script every .5 seconds (since the other stat the player gets is every .5 seconds), then take the Value of the NumberValues as the number of cash to implement to the player.
Here’s the script that I use to update the NumberValue: (StarterGUI, since it has other lines of code changing a Text Label in it)
local leaderstats = game.Players.LocalPlayer:FindFirstChild("leaderstats")
local Multi = leaderstats:FindFirstChild("Multiplier")
while wait(.5) do
local formula = (Multi.Value/1.5)
game.ReplicatedStorage.Cash1.Value = formula*100*(3600/2)
end
Here’s the developer product script (ServerScriptService):
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local StarerGui = game:GetService("StarterGui")
local productID = 1347531300
local function ProcessReceipt(ReceiptInfo)
print("Proccessing reciept")
local Player = Players:GetPlayerByUserId(ReceiptInfo.PlayerId)
if not Player then
warn("Player is not ingame, not yet proccessed payment")
return Enum.ProductPurchaseDecision.NotProcessedYet
end
print(string.format("%s has %i cash, incrementing by %i", Player.Name, Player.leaderstats.Cash.Value, game.Workspace["Usefull Informations"].DevProducts.Cash.Cash1.Value))
Player.leaderstats.Cash.Value += game.ReplicatedStorage.Cash1.Value
print("Purchase granted")
print(game.ReplicatedStorage.Cash1.Value)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = ProcessReceipt
So when I buy the developer product, here is the output I get:
If I change game.ReplicatedStorage.Cash1.Value
by a value like I don’t know, 100, it works perfectly fine, so the problem doesn’t come from the developer product script itself. By the way, in the studio if I click on the value, it does change while in game:
I have no idea why it does this, please help!