#3D Main Menu

42 messages · Page 1 of 1 (latest)

cosmic aspen
#

script:

#
-- // Services \\ --
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local StarterGui = game:GetService("StarterGui")

-- // Locals \\ --
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer.PlayerGui

local MenuGUIs = StarterGui.Menu

local Remotes = ReplicatedStorage.Remotes

-- // GUIs \\ --
local Credits = MenuGUIs.Credits:Clone()
local MainMenu = MenuGUIs.MainMenu:Clone()
local CreditsPage = MenuGUIs.CreditsGui:Clone()
local Settings = MenuGUIs.Settings:Clone()
local SettingsPage = MenuGUIs.SettingsGui:Clone()

Credits.Parent = PlayerGui
MainMenu.Parent = PlayerGui
CreditsPage.Parent = PlayerGui
Settings.Parent = PlayerGui
SettingsPage.Parent = PlayerGui

-- // Camera \\ --
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable

local GoTo = Instance.new("StringValue")
GoTo.Value = "MainMenu"
GoTo.Name = "GoTo"
GoTo.Parent = Camera

local Menu = workspace.Menu
local CameraParts = Menu.CameraParts

Camera.CFrame = CameraParts[GoTo.Value].CFrame
RunService.RenderStepped:Connect(function()
    local GoToPosition = CameraParts[GoTo.Value].CFrame
    GoToPosition += Vector3.new( math.cos( tick() * 5) * .05, math.sin( tick() * 5) * .05, math.cos( tick() * 5) * .05 )
    Camera.CFrame = Camera.CFrame:Lerp(GoToPosition, .1)
end)

-- // Buttons \\ --
local StartBtn = MainMenu.StartButton
local CreditsBtn = MainMenu.CreditsButton
local BackBtn = Credits.MainMenu
local SettingsBtn = MainMenu.SettingsButton
local SettingsBackBtn = Settings.MainMenu

local function regButton(Button: TextButton)
    Button.MouseButton1Click:Connect(function()
        GoTo.Value = Button.Name
    end)
end

-- // Registering Buttons \\ --
regButton(CreditsBtn)
regButton(BackBtn)
regButton(SettingsBtn)
regButton(SettingsBackBtn)
#

tween (in button)```lua
local tweenService = game:GetService("TweenService")

local button = script.Parent

button.MouseEnter:Connect(function()
local tween = tweenService:Create(button, TweenInfo.new(0.2), { TextSize = 40, TextColor3 = Color3.fromRGB(194, 194, 194) })
tween:Play()
end)

button.MouseLeave:Connect(function()
local tween = tweenService:Create(button, TweenInfo.new(0.2), { TextSize = 35, TextColor3 = Color3.fromRGB(255, 255, 255) })
tween:Play()
end)```

#

I'd be grateful if someone will help me

#

starter gui

#

workspace

muted ridge
#

use PlayerGui or get the menu from a script.Parent.Parent chain

fluid sluice
#

in a local script:

local players = game:GetService("Players")
local Player = players.LocalPlayer
local playergui = Player.PlayerGui
#

to get playergui

cosmic aspen
muted ridge
#

also why are u manually cloning the objects

#

the game automatically clones the objects in startergui into every player's playergui

#

so you dont need to do it yourself

cosmic aspen
#

so I gotta clone it and then MenuGUIs.Parent = PlayerGui right?

cosmic aspen
#
local MenuGUIs = StarterGui.Menu:Clone()
MenuGUIs.Parent = PlayerGui```
muted ridge
#

you only need to reference the menu in the PlayerGui, the same way u would in startergui

#

like

local MenuGUis = PlayerGui.Menu
cosmic aspen
#

so just that

muted ridge
#

its better to just place the script under the menu and get it via script.Parent

#

since the script also gets cloned into PlayerGui

cosmic aspen
#

now it's like that

#

MainMenu is the script I sent

#
local MenuGUIs = PlayerGui:WaitForChild("Menu")```
#

when the script wasn't in menu, then it showed infinite yield

muted ridge
#

im not sure

cosmic aspen
#
local MenuGUIs = script.Parent -- PlayerGui:WaitForChild("Menu")```
heady doveBOT
#

studio** You are now Level 8! **studio

cosmic aspen
#

when I did that

cosmic aspen
#
-- // Locals \\ --
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer.PlayerGui

local MenuGUIs = script.Parent -- PlayerGui:WaitForChild("Menu")

local Remotes = ReplicatedStorage.Remotes

-- // GUIs \\ --
local Credits = MenuGUIs.Credits:Clone()
local MainMenu = MenuGUIs.MainMenu:Clone()
local CreditsPage = MenuGUIs.CreditsGui:Clone()
local Settings = MenuGUIs.Settings:Clone()
local SettingsPage = MenuGUIs.SettingsGui:Clone()

Credits.Parent = PlayerGui
MainMenu.Parent = PlayerGui
CreditsPage.Parent = PlayerGui
Settings.Parent = PlayerGui
SettingsPage.Parent = PlayerGui```
muted ridge
#

and you can't parent them to playergui, they have to be under a screengui

#

so just reference the already existing credits and whatnot without cloning or parenting