How can I fix this error?

Hello! I’m trying to make a Battle Shop, but for some reason this script keeps popping up

09:39:55.230  GamePassStore is not a valid member of Player "Players.NubblyFry"  -  Client - ClickRedgerect:2
  09:39:55.233  Stack Begin  -  Studio
  09:39:55.234  Script 'Players.NubblyFry.PlayerGui.BattleShop.BattleShopFrame.GamePassShopButton.ClickRedgerect', Line 2  -  Studio - ClickRedgerect:2
  09:39:55.235  Stack End  -  Studio

Here is the redirect script

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Parent.Parent.GamePassStore.Frame.Visible = true
	script.Parent.Parent.Parent.Parent.Parent.GamePassStore.TextButton.Visible = true
	script.Parent.Parent.Visible = false
	script.Parent.Parent.Parent.TextLabel.Visible = false
end)

You have a lot of .Parents you should use variables to reduce this and you probably used extra or not enough .Parent to get GamePassStore

Since you’re referring to a player, you have to go through playergui.

Instead of doing script.Parent.Parent.Parent.Parent.Parent. I recommend doing:

local PlayerGui = game.Players.LocalPlayer.PlayerGui

script.Parent.MouseButton1Click:Connect(function()
	PlayerGui.GamePassStore.Frame.Visible = true
    PlayerGui.GamePassStore.TextButton.Visible = true
	script.Parent.Parent.Visible = false
	script.Parent.Parent.Parent.TextLabel.Visible = false
end)