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?
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.