Help By Game Pass That Gives You More Cash On Rob

Hello!
I got script instructions from a YouTuber. It is a system with which you can carry out a robbery and get money with it. But I would like to add a Game Pass, which gives you more money. However, this does not work even though I have the Game Pass. There is also no place marked in red. Can you help me?
(I’m a noob in scripting …)

Here is the script:

local prox = script.Parent
local amount = 200 --Money (normal without Game pass)
local openTime = 10 --Open Time
local disable = false
local id = 17330628 --Game pass ID

prox.Triggered:Connect(function(player)
	local Gui = script["TextShop"]:Clone()
	if player.Team.Name == "Criminal" then
		if disable == false then
			Gui.Parent = player.PlayerGui
			Gui.TextLabel.Text = "Robbed!"
			Gui.TextLabel.Script.Disabled = false
			script.Parent.Parent.Parent.Active.BrickColor = BrickColor.new("Crimson")
			player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + amount
			game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) --Analysis, do the player has the game pass?
				if purchased and id == ido then
					player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 250-- How much it now must give (when the player has game pass)
				end
			end)
			disable = true
			wait(openTime)
			script.Parent.Parent.Parent.Active.BrickColor = BrickColor.new("Forest green")
			disable = false
		elseif disable == true then
			Gui.Parent = player.PlayerGui
			Gui.TextLabel.Text = "You robbed too much times."
			Gui.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
			Gui.TextLabel.Script.Disabled = false
		end
	else
		if disable == true then
			Gui.Parent = player.PlayerGui
			Gui.TextLabel.Text = "The Shop Is Closed. Try Again Later"
			Gui.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
			Gui.TextLabel.Script.Disabled = false
		else
			if not player.PlayerGui:FindFirstChild("DoughnutShop") then
				script.DoughnutShop:Clone().Parent = player.PlayerGui
			end
		end
	end
end)

Can you help me please?

Please, if you want to share some code use `````` :slight_smile:

1 Like

Oh… OK! Sorry… Wait I edit…

1 Like

OK, I edited it. Can you help me?

1 Like

I think this isn’t working because the MarketplaceService.PromptGamePassPurchaseFinished event will only fire when the gamepass is purchased, and not if the player owns the gamepass.
If you want to check if the player owns the gamepass you need to use UserOwnsGamePassAsync.

3 Likes

OK! I will try it! Thank you very much!

1 Like

Im sooooo sorry, but that wasn’t it :confused:. But Thx for answer! Do you know something other?
When not, thx, for replying.! :slight_smile:

1 Like

There’s nothing in the output?
Maybe you could send me some errors.

1 Like

I look…
Wait a moment… There must be something

1 Like

Is here something? Theres something with leaderstats, that why I thinked…

14:40:07.701 Stack Begin - Studio
14:40:07.701 Script ‘cloud_180912717.HealthBarPlugin.EnteredHealthScript’, Line 12 - Studio
14:40:07.701 Stack End - Studio
14:40:07.718 Cash is not a valid member of IntValue “Players.Jonasistobercool.leaderstats” - Client - LocalScript:3
14:40:07.719 Stack Begin - Studio
14:40:07.719 Script ‘Players.Jonasistobercool.PlayerGui.CashGUI.TextLabel.LocalScript’, Line 3 - Studio - LocalScript:3
14:40:07.719 Stack End - Studio
14:40:07.901 :: Adonis :: Loading Complete; Required by 0.17714162021325.Loader.Loader - Server
14:40:08.056 Plugin “Fall Damage Plugin [FIXED]” was denied script injection permission. You can grant this permission in the Plugin Manager. - Client
14:40:08.056 Stack Begin - Studio
14:40:08.056 Script ‘cloud_1248186463.FallDamage.AddFallDamage’, Line 6 - function fallDamage - Studio
14:40:08.056 Stack End - Studio
14:40:22.334 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:22.334 Stack Begin - Studio
14:40:22.334 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:22.334 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:22.334 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:22.335 Stack End - Studio
14:40:22.600 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:22.601 Stack Begin - Studio
14:40:22.601 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:22.601 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:22.601 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:22.602 Stack End - Studio
14:40:29.733 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:29.734 Stack Begin - Studio
14:40:29.734 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:29.734 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:29.734 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:29.735 Stack End - Studio
14:40:29.884 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:29.884 Stack Begin - Studio
14:40:29.884 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:29.884 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:29.885 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:29.885 Stack End - Studio
14:40:30.134 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:30.134 Stack Begin - Studio
14:40:30.134 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:30.134 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:30.134 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:30.135 Stack End - Studio
14:40:30.566 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:30.567 Stack Begin - Studio
14:40:30.567 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:30.567 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:30.567 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:30.567 Stack End - Studio
14:40:30.800 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:30.800 Stack Begin - Studio
14:40:30.800 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:30.800 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:30.801 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:30.801 Stack End - Studio
14:40:31.817 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:31.817 Stack Begin - Studio
14:40:31.817 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:31.817 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:31.818 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:31.818 Stack End - Studio
14:40:32.367 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:32.367 Stack Begin - Studio
14:40:32.367 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:32.367 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:32.368 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:32.368 Stack End - Studio
14:40:32.533 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:32.534 Stack Begin - Studio
14:40:32.534 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:32.534 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:32.534 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:32.534 Stack End - Studio
14:40:33.017 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:33.017 Stack Begin - Studio
14:40:33.017 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:33.017 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:33.018 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:33.018 Stack End - Studio
14:40:33.717 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:33.717 Stack Begin - Studio
14:40:33.717 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:33.718 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:33.718 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:33.718 Stack End - Studio
14:40:34.250 cloud_142731176._Char:93: attempt to index nil with ‘Head’ - Client
14:40:34.250 Stack Begin - Studio
14:40:34.250 Script ‘cloud_142731176._Char’, Line 93 - function updateMovement - Studio
14:40:34.250 Script ‘cloud_142731176._Char’, Line 430 - Studio
14:40:34.251 Script ‘cloud_142731176._Char’, Line 497 - Studio
14:40:34.251 Stack End - Studio
14:40:43.799 Cash is not a valid member of IntValue “Players.Jonasistobercool.leaderstats” - Server - Script:15
14:40:43.799 Stack Begin - Studio
14:40:43.800 Script ‘Workspace.Shop.ProxPart.ProximityPrompt.Script’, Line 15 - Studio - Script:15
14:40:43.800 Stack End - Studio

Oh, could you send me how your rob script is now?
Your output is pretty messy because the amount of scripts in your game…

1 Like

OK! I do it… must wait a sec. But wait, theres a proof, that it don’t works. The GUI don’t shows me my cash…

The model. (Without the other things).rbxm (28.5 KB)

Oh, so are you sure that “leaderstats” is a folder inside the player?
Because in this line we can see that it is an IntValue, look:

The leaderstats must be a folder because it can store multiple values inside of it, and show them in the players tab.

It is in a folder. I maked the leaderstats as this:

local DSS = game:GetService("DataStoreService")
local DataStore = DSS:GetDataStore("DataStore")

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local Cash = Instance.new("IntValue")
	Cash.Name = "Cash"
	Cash.Parent = leaderstats
	
	local data
	local success, errorMessage = pcall(function()
		data = DataStore:GetAsync(player.UserId)
	end)
	if success and data ~= nil then
		print("Data successfully loaded!")
		Cash.Value = data.Cash
	else
		warn(errorMessage)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local leaderstats = player.leaderstats
	local data = {
		Cash = leaderstats.Cash.Value;
	}
	local success, errorMessage = pcall(function()
		DataStore:SetAsync(player.UserId,data)
	end)
	if success then
		print("Data successfully saved!")
	else
		warn(errorMessage)
	end
end)

Oh wait, ignore this.
I got it wrong.

1 Like

Maybe there’s some script creating another leaderstats folder.
When you are playing, go to Players => YourName => leaderstats => and then check if there is a value inside of it.

1 Like

OK… How do you mean that? Idk

When you are in the play mode, go to the explorer and do what I said. Then tell me if there’s some IntValue inside the leaderstats folder.
If there isn’t, that could be a problem…

1 Like

OK! But that is only, when a script don’t works (in the entire game) sorry, that I say it now… But what is now with the rob system? It still don’t works… Sorry, that i’m taking so much time :frowning: