I have a buy cash gui but when i do a text purchase, it doesnt add 500 cash. here is the script.
local buyButton = script.Parent
local productId = 92041867 --change to dev product id
local mps = game:GetService"MarketplaceService"
function getPlayerById(id)
for i,v in pairs(game.Players:GetPlayers()) do
if v.userId == id then
return v
end
end
end
buyButton.MouseButton1Click:connect(function()
mps:PromptProductPurchase(game.Players.LocalPlayer, productId)
end)
mps.ProcessReceipt = function(info)
local plr = getPlayerById(info.PlayerId)
if plr and plr:FindFirstChild"leaderstats" and plr.leaderstats:FindFirstChild"Cash" then
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 500
end
end
Here is my leaderboard script -- also sometimes instead of saying cash, it says value and I dont know why.
local playerLeaderstats = {}
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local rank = Instance.new("StringValue", leaderstats)
rank.Name = "Rank"
rank.Value = player:GetRoleInGroup(3309505)
playerLeaderstats[player] = {}
playerLeaderstats[player]["Cash"] = 100
local money = Instance.new("IntValue", leaderstats)
money.Name = "Cash"
money.Value = playerLeaderstats[player]["Cash"]
while wait(5) do
playerLeaderstats[player]["Cash"] = playerLeaderstats[player]["Cash"] + 1
if player:FindFirstChild("leaderstats") ~= nil then
player.leaderstats.Cash.Value = playerLeaderstats[player]["Cash"]
end
end
end)

2 comments
What game is this for? A tycoon? If it is a tycoon, are you using a tycoon kit?
No, its not a tycoon. Here I will put in my leaderboard so that people can understand because None of these work and I think its my leaderboard's problem