Scripting help (gui)

Hello, I am trying to make a script that appears or disappears uis.
I made this code in a LocalScript in starterplayerscript
I get this error FirstFrame is not a valid member of PlayerGui “Players.anakin67001.PlayerGui”
I’ll give you the screenshots and the

local Players = game:WaitForChild("Players")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local blur_effect = game.Lighting.Blur

local function setupUI(buy, info_frame, buy_frame, Back_boutton)
	buy.MouseButton1Click:Connect(function()
		blur_effect.Enabled = true
		info_frame.Visible = false
		buy.Visible = false
		buy_frame.Visible = false
		wait(1)
		blur_effect.Enabled = false
		Back_boutton.Visible = true
	end)
end

local Etape1 =  playerGui.FirstFrame.Frame
local buy_frame1 = playerGui.Frame.Claim
local Back_boutton1 = playerGui.Frame.Back
setupUI(Etape1, buy_frame1, Back_boutton1)

local buy2 = playerGui.SecondUI.Buy
local info_frame2 = playerGui.SecondUI.InfoFrame
local buy_frame2 = playerGui.SecondUI.BuyFrame
local Back_boutton2 = playerGui.SecondUI.BackButton
setupUI(buy2, info_frame2, buy_frame2, Back_boutton2)

Thanks

1 Like

FirstFrame might exist but just make it playerGui:WaitForChild(“FirstFrame”).Frame

if frame errors, just make it waitforchild too.

The client loads faster than instances. You will probably encounter that problem with the other parts of the script.

1 Like
local buy_frame1 = playerGui:WaitForChild('Frame' ,'Claim')
local Back_boutton1 = playerGui:WaitForChild('Frame' ,'Back')
setupUI(Etape1, buy_frame1, Back_boutton1)

The script doesn’t work and when I click on the button it gives this error

image

Why did you decide to use :WaitForChild on a GetService?
Replace local Players = game:WaitForChild("Players") with local Players = game:GetService("Players") and keep the WaitForChild for the Frame.