I am trying to implement Developer Products into my game and want to use RemoteEvents to communicate to the server how much gold (my currency) to add to a certain player. There are a couple different products, each one that provides a different amount of gold for a different amount of robux.
The issue I am experiencing is that although the communication between Client and Server successfully works, the desired amount is never being added; the amount always remains at 0.
I have a picture of what the page looks like to a user.
Basically you choose from a DropDown menu that has fixed options to buy gold - 25, 50, 100, 250, etc. When you choose one of the options (all options are separate TextButtons), it changes two IntValues. One IntValue is edited to contain the value of the Developer Product that would be bought in the event that the user chooses to purchase. The other value is edited to have as much gold would be earned by the player in that same event. In the scripts down below, you can see how they are utilized.
I attached some snippets of my code down below.
This is a LocalScript I had attached to a button, which prompts the purchase.
local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local AddGold = game.ReplicatedStorage.DevProduct_AddGold --RemoteEvent script.Parent.Activated:Connect(function(player) local productID = script.Parent.Parent.DevProductID.Value --IntValue that holds the current selection's value local productInfo = MarketplaceService:GetProductInfo(productID, Enum.InfoType.Product) local player = Players.LocalPlayer MarketplaceService:PromptProductPurchase(player, productID) MarketplaceService.PromptProductPurchaseFinished:connect(function(userId, productId, isPurchased) if isPurchased then if productId == 998890745 then AddGold:FireServer() --Should reward 25 gold to the player end end end) end)
Now for my Script in ServerScriptStorage:
--Note that AddValue is an IntValue in StarterGui that represents how much gold should be given once something is purchased. game.ReplicatedStorage.DevProduct_AddGold.OnServerEvent:Connect(function(player) local leaderstats = player.leaderstats local gold = leaderstats.Gold local addValue = game.StarterGui.MenuGUI.RobuxShopPage.MenuFrame.BuyGoldFrame.Frame.AddGold.Value print(addValue) --This prints, but the value always stays at 0 gold.Value = gold.Value + addValue end)
So far, I have tried many solutions. I tried adding the desired value as a parameter to
FireServer(), which made it
FireServer(25). It never worked, and I added Print statements throughout the code. Everything was executing properly and was going through, but the
addValue.Value never changed.
Sorry for writing such a long description, wanted to provide as much information as possible. Anyone have any ideas as to how I could make this work? Any help would be appreciated.