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

How can I get this gamepass money script to give players money?

Im trying to make a script that gives a regular player 10 dollars every 3 seconds, and a player with a specific gamepass 20 dollars every 3 seconds. I have written up a script that doesnt seem to work and I'd like some assistance. It doesnt seem to give anyone money at all.

print("2X Money Activated")
local MarketplaceService = game:GetService("MarketplaceService")
local gamePassID = 5068130

function onPlayerEntered(newPlayer)
	local money = newPlayer.BRB
	if MarketplaceService:UserOwnsGamePassAsync(newPlayer.UserId, gamePassID) then
		wait(3)
	money.Value = money.Value + 20 else
	money.Value = money.Value + 10
	end
end


game.Players.ChildAdded:connect(onPlayerEntered)

1 answer

✓ Accepted answer

First of all, that would give you money after 3 seconds you join. Also, you don't know if BRB loaded in yet. there is an easy way to do this.

function onPlayerEntered(newPlayer)
	    local money = newPlayer:WaitForChild('BRB')
	    if MarketplaceService:UserOwnsGamePassAsync(newPlayer.UserId, gamePassID) then	  
      	  coroutine.wrap(function()
		while true do
		   wait(3)
	    money.Value += 20 -- New format
		end
		end)() -- Ending coroutine and calling it
	else
      	  coroutine.wrap(function()
		while true do
		   wait(3)
	    money.Value += 10-- New format
		end
		end)() -- Ending coroutine and calling it
	    end
	end
	 
 
	game.Players.ChildAdded:connect(onPlayerEntered)

2 comments

0

Sorry for the indentation

0

Thank you

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