Infinite Cash Gamepass

Hello I am trying to make a Infinite Cash gamepass so it sets your cash to 10billion every time you join but for some reason it shows that it is at 10billion but if I gain any more cash it resets it back to what I gained such as 1.

local solariId = 18993213
local marketplaceService = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
	if (marketplaceService:UserOwnsGamePassAsync(player.UserId, solariId)) then
		player:WaitForChild("leaderstats"):WaitForChild("Solari").Value = "10.0B+"
    end
end)

The script is in serverscriptservice and it is not a local script

1 Like

Because "10.0B+" is not in a valid format Lua expects it to be. What do you expect?

2 Likes

then why does it show that there is 10b when I join the game

1 Like

I think you need to put an actual number instead of the string.

2 Likes

Same issue I put it as 10000000 and it just set it back to 1 when I gained money

1 Like

Maybe add 10b to the original value instead of setting it equal to 10b? Don’t know if that will actually work lol. Just an idea.

I have a feeling what’s causing the issue isn’t in the script you provided, but in the other script where the cash earning is done.

1 Like

I am using Zed’s tycoon kit is there an issue with that maybe

1 Like

I’m not familiar with the kit, can you send the code where the cash earning is done?

1 Like

I think the other script utilizes a datastore to save the current cash amount of a player, and what your script does is just change the leader stat. It probably isn’t overriding that saved data.

1 Like

This is the script I think

script.Parent.Essentials.Giver.Touched:connect(function(hit)
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player ~= nil then
			if script.Parent.Owner.Value == player then
				if hit.Parent:FindFirstChild("Humanoid") then
					if hit.Parent.Humanoid.Health > 0 then
						if deb == false then
							deb = true
							script.Parent.Essentials.Giver.BrickColor = BrickColor.new("Bright red")
							local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
							if Stats ~= nil then 
							Sound(script.Parent.Essentials, Settings.Sounds.Collect)
							Stats.Value = Stats.Value + Money.Value
							Money.Value = 0
							wait(1)
							script.Parent.Essentials.Giver.BrickColor = BrickColor.new("Sea green")
							deb = false
							end
						end
					end
				end
1 Like

Maybe there is a thing that modifies the value. So that is why your cash resets.

1 Like

I might just re-write the entire tycoon at this point zed’s tycoon kit is so old and many things are broken with it

1 Like

Apparently, the kit makes a folder in ServerStorage called PlayerMoney that contains the money value of each player in the game. I think that’s the value you gotta change to 10 billion in order for your gamepass to work.

1 Like

Oh I’m pretty sure I seen that somewhere in the script, let me try finding it thanks

1 Like

It’s this code here that made me think that way

1 Like

Maybe he can do this:

local solariId = 18993213
local marketplaceService = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
	if (marketplaceService:UserOwnsGamePassAsync(player.UserId, solariId)) then
		Stats.Value = 1000000000
    end
end)

I’m not sure if this is a LocalScript so that’s my guess.

3 Likes

yay Thank you very much! For anyone needing the code,

local solariId = 18993213
local marketplaceService = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
	if (marketplaceService:UserOwnsGamePassAsync(player.UserId, solariId)) then
		local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
		Stats.Value = 10000000
    end
end)
7 Likes

Hey, I’m trying to figure out how to do the same thing as you did. I tried using the script that worked for you but it’s not working for me, do you know why?

I put this script below in a server script inside of ServerScriptService.

local GamepassId = 38729509
local marketplaceService = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
	if (marketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId)) then
		local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
		Stats.Value = 99000000
	end
end)

The LocalScript inside of the TextButton that prompts the purchase is:

local GamepassId = 38729509

script.Parent.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, GamepassId)
end)

The button that prompts the purchase works but it does not give the player any money. (Nothing at all happens)

Your code only checks if the player owns the game pass when they join, it doesn’t account for if they purchase it while in-game.

You’d want to take a look at this:
https://developer.roblox.com/en-us/api-reference/event/MarketplaceService/PromptGamePassPurchaseFinished

I know nothing about scripting that’s why I’m using free models (Zed’s Tycoon Kit). Is there a tutorial out there on how to set up the PromptGamePassPurchaseFinished?