This button script wont work

I’m making a button gui for a multiplayer game but then
an error pops up saying “JoinServerGui is not a valid member of PlayerGui”
Here’s how its organized:

Example

and here’s the script:

local Button = script.Parent.ServerGUI.MainFrame.Frame.MultiPlayer
local Frame = script.Parent.JoinServerGUI.Frame
local BoolValue = script.Parent.JoinServerGUI.Frame.Frame.ImageLabel.Bool.Value

Button.MouseButton1Down:Connect(function()
	BoolValue = true
	Frame.Visible = true
end)

the script above (^) is the “CharacterScript”

Sometimes, scripts load and execute code before the game loads in everything to the player. That’s where WaitForChild comes into play.
I’ve made a basic change to your code, try the code I posted above.

^ There are a lot of ways to fix it, not just WaitForChild.

3 Likes

As said @triixys
There is more way to fix this like this:

repeat 
wait()
until script.Parent:FindFirstChild("JoinServerGUI")
-- Do your code

This code will wait until it will found the thing you looking for
After that the code continue after the thing was found