Gamepass Issue with extra money

Hey there, So I’m making a gamepass where you get more money if you buy it and my script don’t work

my code:

local gamepass_id = 46359762
local stat = "Cash"
local gamepass_stat = 5000
--End of Settings

game.Players.PlayerAdded:Connect(function(player)
	local fold = Instance.new("Folder", player)
	fold.Name = "leaderstats"
	local val = Instance.new("IntValue", fold)
	val.Name = "Cash"
	val.Value = 0
	
	local awarded = Instance.new("BoolValue", player)
	awarded.Name = "Awarded"
	
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepass_id) and player.Awarded.Value == false then
		player.Awarded.Value = true
		val.Value = val.Value + gamepass_stat
	end
end)

while wait(3) do
	for i,v in pairs(game.Players:GetChildren()) do
		if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(v.UserId, gamepass_id) and v:WaitForChild("Awarded").Value == false then
			v.Awarded.Value = true
			v.leaderstats:FindFirstChild(stat).Value = v.leaderstats:FindFirstChild(stat).Value + gamepass_stat	
		end
	end
end

Script works fine for me, make sure the gamepass is a working one (I believe your game must be public for that)

Sorry for late response I didn’t get a notification. Anyways this this work instantly?

Because if so this didn’t work for me I get it when testing in Roblox studio

I got a suggestion. If you are having them buy cash, you’re better off using dev products, as they can buy it multiple times and there would be another way to check if they had bought it, which in return would give them the money a lot quicker. Do you know how dev products work? If not, can we find a way to talk outside of the forum (like discjord or something) so I can walk you through how to do it? A bit hard to do it through here.

I have a dev product script that works perfectly I don’t know why i didn’t think of that thank you!

1 Like