Hey guys and gals!
I’m creating a solo game, and I’ve gotten a lot done so far, but now I’d like to remake my main menu. The only issue is that I have no clue how to script. I’ve tried using Roblox’s Assistant feature, and even ChatGPT, but all of the outputs come with errors that I cannot solve. This is one of the responses I’ve received. The GUI just disappears and shows the black screen. It doesn’t fade or anything, and never shows the main menu.
local screenGuiStartingMenu = game.Players.LocalPlayer.PlayerGui:WaitForChild("StartingMenu")
local frameStartingMenu = screenGuiStartingMenu:WaitForChild("StartingMenuFrame")
local screenGuiBlackScreen = game.Players.LocalPlayer.PlayerGui:WaitForChild("BlackScreen")
local frameBlackScreen = screenGuiBlackScreen:WaitForChild("Frame")
local screenGuiMainMenu = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainMenu")
local frameMainMenu = screenGuiMainMenu:WaitForChild("Menu")
local function fadeFrame(frame, targetTransparency, duration)
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local tweenProperties = { BackgroundTransparency = targetTransparency }
local tween = game.TweenService:Create(frame, tweenInfo, tweenProperties)
tween:Play()
tween:Wait() -- Wait for the tween to complete before continuing
end
local function handleKeyPress()
print("Key pressed")
-- Disable the StartingMenu
frameStartingMenu.Parent.Enabled = false
-- Fade out StartingMenu to black over 2 seconds
fadeFrame(frameStartingMenu, 1, 2)
-- Wait for 2 seconds at full transparency
wait(2)
-- Enable MainMenu and fade from BlackScreen to MainMenu over 2 seconds
frameMainMenu.Parent.Enabled = true
fadeFrame(frameBlackScreen, 1, 0.5) -- Fade to black over 0.5 seconds
fadeFrame(frameMainMenu, 0, 2) -- Fade from black to MainMenu over 2 seconds
end
game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(key)
handleKeyPress()
end)
print("Script is running")
When you join the game, it takes you straight to the menu, where you can hit play and change settings, but I’d like to make a “Press Any Key to Start” kind of menu, with a transition to the menu.
Any other topics I’ve found seem to be outdated or not working.
Any help would be appreciated. Thanks!