Vip Cash Script

I made a script that gives players who own the Vip gamepass +5 Cash every 60 seconds but it’s not working, can anyone tell me why?

Here’s it:

local mps = game:GetService("MarketplaceService")
local vip = 13261240

game.Players.PlayerAdded:Connect(function(plr)
	if mps:PlayerOwnsAsset(plr, vip) then
		while wait(60) do
			plr.leaderstats.Cash.Value += 5
		end
	end
end)

I think it’s probably because you didn’t do CharacterAdded event, you should do it because in this case if a player respawns, they won’t get their cash anymore as PlayerAdded event only FIRES when a new player joins the game, not when your character is loaded.

How would i do it then? I know what it is but i never used the CharacterAdded event.

Edit: Even tho i didn’t respawn the player and still didn’t get the money

Probably because you had to do:

plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 5

+= is a short for not having to do all of that

so instead of

Value = Value + 1

i use

Value += 1

It’s an event of the player. So it will be:

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function()
        — do stuffs here.
    end)
end)

That’s literally the same thing.

Since he also doesnt wrap the while loop on a spawn function or a coroutine, its just pauses the whole script when a player enters

I changed the script to:

local mps = game:GetService("MarketplaceService")
local vip = 13261240

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function()
		if mps:PlayerOwnsAsset(plr, vip) then
			while wait(1) do
				plr.leaderstats.Cash.Value += 5
			end
		end
	end)	
end)

And it still doesn’t work

Also the output shows no error

I think u need to use UserOwnsGamePassAsync for this

1 Like

I’m not experience with MarketplaceService, but I believe there’s another function to check if a player owns a gamepass or not.

1 Like

Yup, It’s UserOwnsGamePassAsync.