Function not recognizing my gui

Good Evening / Morning,

I’ve been working on a main menu that script that does a few things. I’ve run into an error that when trying to transition to my Character edit menu it doesn’t recognize the GUI that is supposed to display all the character information.

Here is the script that is ran when the button is clicked


-- Create Out Tween for Main Side bar --
local tweenBarOut = TweenService:Create(script.Parent.Parent,
	TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0), {Position = UDim2.new(-1.125, 0,0.5, 0)})
	
local tweenCharIn = TweenService:Create(Player.PlayerGui.characterGUI,
	TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0), {Position = UDim2.new(-1.125, 0,0.5, 0)})
	
			
local function onButtonActivated()
	tweenBarOut:Play()
	print("Moving GUI")
	tweenBarOut.Completed:Wait()
	print("Moved")
	transBG()
	Camera.CameraType = "Scriptable"
	Camera.CFrame = game.Workspace.CamPartChar.CFrame
	transBG()
	tweenCharIn()
end

script.Parent.Activated:Connect(onButtonActivated)

Whenever I launch the game I get the error “characterGUI is not a valid member of PlayerGui”

Any help would be much appreciated!

1 Like

Please make sure to format the code so we can better understand it!

1 Like

Thanks, few questions, is this script a client or server side script? Is it running as soon as the game starts. Does “characterGUI” actually exist?

It’s a client sided local script rooted under a button on my main gui. And characterGUI does exist, even when I go ingame it’s under PlayerGui.

At the beginning of your local script add

Player.PlayerGui:WaitForChild("characterGUI")

Your error is most likely happening becuase characterGUI may have not actually loaded in yet.

1 Like

Heh! Well that seems to work. :sweat_smile: I tried this earlier but it didnt seem to work that time. Must’ve been too tired. Thank you!

1 Like