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)