Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I add a 2x cash game pass to my tycoon?

I'm currently making a tycoon and I'm trying to make a game pass that doubles your cash. I already know how to make the actual game pass, but the scripting part is difficult for me. I want to make it so that when a player who owns the game pass goes to collect their money from the money collector, they get double the amount of money than what they'd normally get. I'm not necessarily asking for a script (if you could provide a script as an example it would help a lot), but how can I do this and where would I put the script?

2 answers

So uh you would want it to be a Server Script in ServerScriptService. it would have to have a reference to the MarketplaceService. which you can do by doing

local market = game:GetService("MarketplaceService")

then, do a PlayerAdded function which checks for the gamepass, and somehow make everything give the player double coins if the player has the gamepass.

There is no "Double cash" script on its own, it's not possible. Instead, you have to go to each of your scripts that gives cash, On that script check if they own the gamepass, then give double. Otherwise, only give the standard amount. You can do it like this:

This script will give you 50 cash when you enter the game, if you have the gamepass it will give you 100 cash on a server script:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local amountgiven = 50 - how much you want given
 
local gamePassID = 0000000  -- Change this to your game pass ID
 
local function onPlayerAdded(player)
 
	local hasPass = false
 
	-- Check if the player already owns the game pass
	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
	end)
 
	-- If there's an error, issue a warning and exit the function
	if not success then
		warn("Error while checking if player has pass: " .. tostring(message))
		return
	end
 
	if hasPass == true then -- they have the gamepass
		print(player.Name .. " owns the game pass with ID " .. gamePassID)
                player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + (amountgiven*2) -- change "Cash" to whatever your currency name is
        else
                player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + amountgiven -- same here
	end
end
 
-- Connect "PlayerAdded" events to the "onPlayerAdded()" function
Players.PlayerAdded:Connect(onPlayerAdded)

Also, in the future make sure to tell us what you have tried, and give us a script to work with. But i hope this has been of help, if it has helped you please accept this answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.