Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this script for a game pass not working?

Asked by 9 years ago

This code that i have edited to give someone $25,000 if they buy my vip pass, does not seem to work and im not sure why. If you are wondering why their is no section for the game pass id, it's because there is an IntValue where i put it

--------------------
--| WaitForChild |--
--------------------

-- Waits for parent.child to exist, then returns it
local function WaitForChild(parent, childName)
    assert(parent, "ERROR: WaitForChild: parent is nil")
    while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
    return parent[childName]
end

-----------------
--| Variables |--
-----------------

local GamePassService = Game:GetService('GamePassService')
local PlayersService = Game:GetService('Players')
local Leaderboard = Game:GetService('leaderstats')
local LightingService = Game:GetService('Lighting') --TODO: Use new data store service once that exists

local GamePassIdObject = WaitForChild(script, 'GamePassId')


-----------------
--| Functions |--
-----------------

-- When a player with the game pass joins, give them $25,000
local function OnPlayerAdded(player)
    if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then
        player:findFirstChild("leaderstats").money.Value = 25000

        end
    end
end

Answer this question