#3D Main Menu
42 messages · Page 1 of 1 (latest)
-- // 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
ur referencing the ui from StarterGui, when StarterGui is just a container object for cloning its children into every player's PlayerGui
use PlayerGui or get the menu from a script.Parent.Parent chain
in a local script:
local players = game:GetService("Players")
local Player = players.LocalPlayer
local playergui = Player.PlayerGui
to get playergui
I did it here
so wdym
I already did it
here
this is still indexing startergui
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
so I gotta clone it and then MenuGUIs.Parent = PlayerGui right?
no, ^
local MenuGUIs = StarterGui.Menu:Clone()
MenuGUIs.Parent = PlayerGui```
you only need to reference the menu in the PlayerGui, the same way u would in startergui
like
local MenuGUis = PlayerGui.Menu
might need to use WaitForChild
its better to just place the script under the menu and get it via script.Parent
since the script also gets cloned into PlayerGui
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
im not sure
local MenuGUIs = script.Parent -- PlayerGui:WaitForChild("Menu")```
** You are now Level 8! **
when I did that
it's still like this
-- // 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```
you dont need to clone the objects
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