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

Help on gamepass and leaderboard?

Asked by 10 years ago

I can't seem to get my gamepasses to work. My leaderboard works fine, but the gamepasses won't work. In game I get a "Unable to cast value to Object" what does this mean?

Here's my gamepass script (it's in a GUI):

local Player = script.Parent.Parent.Parent.Parent
local GamePassID = 125414272

function onClicked()
    if game:GetService("GamePassService"):PlayerHasPass(Player.userId,GamePassID) then 
      Player:findFirstChild("leaderstats").Cash.Value = 100000
        script.Parent.Visible = false
        else
        game:GetService("MarketplaceService"):PromptPurchase(Player,GamePassID)
    end
end

script.Parent.MouseButton1Click:connect(onClicked)

And here's my leaderboard, if that effects anything (it works fine):


function onPlayerEntered(newPlayer) wait(.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats" local stats2 = Instance.new("IntValue") stats2.Name = "Tycoon" local Cash = Instance.new("IntValue") Cash.Name = "Cash" Cash.Value = 0 Cash.Parent = stats stats2.Parent = newPlayer stats.Parent = newPlayer end game.Players.ChildAdded:connect(onPlayerEntered)

Answer this question