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

Why does the in game gamepass shop gui not work?

Asked by
jacobwow 140
10 years ago

I am making a gui in my game that allows the player to buy the darkheart gamepass while they are in the game. This is the script:

function gamepass()
script.Parent.Parent.Parent.Parent = player
    Game:GetService("MarketplaceService"):PromptPurchase(player, 155387134)
end

script.Parent.MouseButton1Click:connect(gamepass)

However it does not work when I click the button. Is something missing or incorrect?

1 answer

Log in to vote
1
Answered by
User#2 0
10 years ago

The problem is on line two.

script.Parent.Parent.Parent.Parent = player

What that's doing is saying "this script's Parent's Parent's Parent's Parent will be player, which does not currently exists, so instead Parent it to nil"

I believe what you were trying to do was assign player as a variable, in which case the variable name comes first.

player = script.Parent.Parent.Parent.Parent

You may also want to double check your hierarchy, just to be positive you have the correct amount of parents.

Ad

Answer this question