How to make this script for with only gamepass (Tycoon autocollect)

How can i add gamepass in this script and work autocollect gamepass only for who has bought the gamepass

local Tycoon = script.Parent.Parent
local TycoonTeamColor = script.Parent.TeamColor
local CurrencyToCollect = script.Parent.CurrencyToCollect
local Owner = script.Parent.Owner
local Settings = require(script.Parent.Parent.Parent.Settings)
local CurrentPlr = nil
local CurrentPlrId = 0
local cooldown = Settings.AutoCollect.Cooldown

Owner.Changed:Connect(function()
	if Settings.AutoCollect.Collect == true then
		print(Settings.AutoCollect.Collect)
		if Owner.Value ~= nil then
			repeat
				wait(cooldown)
				for i, v in pairs(game:GetService("Players"):GetChildren()) do
					if v.TeamColor == TycoonTeamColor.Value then
						if CurrentPlr ~= v.Name then
							CurrentPlr = v.Name
							local success, err = pcall(function()
								id = game:GetService("Players"):GetUserIdFromNameAsync(CurrentPlr)
							end)
							if success then
								CurrentPlrId = id
							end
							if err then
								print("Error while using :GetUserIdFromNameAsync()")
							end
							print(CurrentPlr)
							print(CurrentPlrId)
						end
						if game.ServerStorage:FindFirstChild("PlayerMoney"):FindFirstChild(v.Name) then
							if CurrencyToCollect.Value ~= 0 then
								game.ServerStorage:FindFirstChild("PlayerMoney"):FindFirstChild(v.Name).Value = game.ServerStorage:FindFirstChild("PlayerMoney"):FindFirstChild(v.Name).Value + CurrencyToCollect.Value 
								CurrencyToCollect.Value = 0
							end
						end
					end
				end
			until Owner.Value == nil
		else
		end
	end
end)
1 Like

Hi!

Here’s what you should do.

  • Make so players can buy the gamepass after all. If players own the gamepass do as following:
  • Go find the script that does, so when they earn money, it goes to the “money-monitor”. Change that, so they directly goes into the players PlayerMoney instead.

If that wasn’t what you were looking for, please specify your issue.

2 Likes