MainFrame is not a valid member

So I’m trying to make a script for a shop but it keeps saying MainFrame is not a valid member of LocalScript “Players.Tunnells.PlayerGui.Shop” - Client

How would I fix it?

local PlayerGui = Player:WaitForChild("PlayerGui")
local Sounds = PlayerGui.Sounds
local Shop = PlayerGui:WaitForChild("Shop")
local BearTrapStuff = PlayerGui.Shop.MainFrame.ItemInfo.BearTrapInfo
debounce = true

PlayerGui.Shop.MainFrame.BearTrap.MouseButton1Click:Connect(function()
	BearTrapStuff.Buy.Visible = true
	BearTrapStuff.BearTrapImage.Visible = true
	BearTrapStuff.BearTrapInfo.Visible = true
	BearTrapStuff.BearTrapPrice.Visible = true
end)

BearTrapStuff.Buy.MouseButton1Click:Connect(function()
	if Player.leaderstats.Points.Value < 500 and debounce == true and Player.Backpack:FindFirstChild("BearTrap") == nil and Player.Character:FindFirstChild("BearTrap") == nil then
		debounce = false
		game.StarterGui.Sounds.WiseChose:Play()
		game.ReplicatedStorage.RemotesShop.BearTrap:FireServer(Player)
		wait(3)
		debounce = true
	end
end)
1 Like

Is your LocalScript named the same as the Shop Frame? If so, rename the localscript

1 Like

Bruh bruh bruh I’m so dumb :sad:

2 Likes

Haha it’s okay! Sometimes seeing mistakes like those can be a bit confusing to see, so make sure to read the error correctly! If you have anymore issues don’t be afraid to make another post!

2 Likes