local mainButtons = script.Parent.Parent["Main Menu"].MainFrame.Buttons
local mainTitle = script.Parent.Parent["Main Menu"].MainFrame.Title
local menuButton = script.Parent.MenuButton
if mainButtons.Visible == false and mainTitle.Visible == false then
menuButton = true
end
game.StarterGui.BringBack.MenuButton.TextButton.MouseButton1Click:Connect(function()
if menuButton.Visible == true then
menuButton = false
mainButtons = true
mainTitle = true
end
end)
This local script is separate from the one that has to deal with the buttons.
When the Gui is cloned to the Player, then the reference to it changes:
-- This is where you created it originally
game.StarterGui.BringBack.MenuButton.TextButton.MouseButton1Click:Connect(function()
-- This is where it gets cloned to
game.Players.LocalPlayer.PlayerGui.StarterGui.BringBack.MenuButton.TextButton.MouseButton1Click:Connect(function()
If you want to create a graphical user interface (GUI), write a script inside the GUI and bind buttons and other components to local variables for easier handling. If you still want to simulate a mouse click, the answer has already been provided above. However, I believe it’s unnecessary; it’s better to have the script directly inside the GUI or within the button for easier development.