I need help with my script

This is my script I don’t understand what I did wrong please help if you can(“JoinGame” and “CreateGame” are Guis)

script.Parent.MouseButton1Click:Connect(function()

game.StarterGui:FindFirstChild(“JoinGame”).Visibility = false

game.StarterGui:FindFirstChild(“CreateGame”).Visibility = true

end)

You must do it from PlayerGui and also, the property is called ‘Visible’, not ‘Visibility’.

Oh thanks I forgot about that.

As @ZOMBEIVEroblox Just mentioned, you’re supposed to use PlayerGui, because PlayerGui is replicated from StarterGui to the Player. Meaning, that you have to control it from their own UI.

Also, MouseButton1Click doesn’t exist, it’s supposed to be MouseButton1Down.

Another thing about PlayerGui, is that you have to use Luau :WaitForChild() method ,since each client is different.

With these issues attacked, our final code would look like this:

local Player = game.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui") --Need this because not all people have super computers lol
local JoinGame = PlayerGui:WaitForChild("JoinGame")
local CreateGame = PlayerGui:WaitForChild("CreateGame")

script.Parent.MouseButton1Down:Connect(function()
     JoinGame.Visible = false
     CreateGame.Visible = true

end)

Hopefully you’ve fixed this issue, I also ask that you take a little bit more time to look at properties before scripting them.

Also, yes, you have to use :WaitForChild whenever getting the path to a GuiObject. It’s just so it doesn’t mess up when trying to load in. Whenever you learn how to use modules, I suggest using ChipoIndustries module, to end the nightmare :joy:

1 Like

MouseButton1Click DOES exist. MouseButton1Down fires the event as soon as your left mouse goes down, MouseButton1Click fires only when you release it after pressing it down.

1 Like