StarterGui is just a folder that contains all the GUIs for your game. When a player spawns, all the items in StarterGui are copied and pasted into that player's PlayerGui object, which is inside the Player. Instead of defining buyButton as game.StarterGui.ShopMain.MoneyButton, it should be something like script.Parent.ShopMain.MoneyButton based on where the LocalScript is in relation to the GUI.
In addition, instead of handling the cash adding on the client, it has to be done on the server by setting the MarketplaceService.ProcessReceipt callback.
ProcessReceipt Example:
http://wiki.roblox.com/index.php?title=ProcessReceipt
So in your case, you might write something like this and put it in a Script (not LocalScript) in ServerScriptService:
local cashProductId= 23342953
local MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetPlayers()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == cashProductId then
local stats = player:FindFirstChild("leaderstats")
if stats ~= nil then
local cash = stats:FindFirstChild("Cash")
cash.Value = cash.Value +3000
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end
end
end
4 comments
code block please
Can you explain a bit more about what is wrong?
First thing I can say is not right, is you do not have a end ('end)') to the function. Also, user doesn't seem to be defined in your script, so the player stats would not change.
I feel bad for people who bought this already qq