I made a Main Menu GUI for 1 game, the code provided is the code I wrote for it, and then I imported this code into another game and I have issues
- after pressing play, the camera is stuck on camerapart, and it wont I cant see my character
- the Hide UIs button doesn’t hide ALL UIs
I tried AI it did not work, I tried YouTube tutorials still stuck
game.StarterGui:SetCore("ResetButtonCallback", false)
local CurrentMusic = game.Workspace:WaitForChild("CurrentMusic")
local SmoothJazz = script:FindFirstChild("Chill Jazz")
local InfowarnTxtLabel = script.Parent.Frame:FindFirstChild("InfoWarn")
local SettingsBtn = script.Parent.Frame:FindFirstChild("SettingsButton")
local HideUIsBtn = script.Parent.Frame:FindFirstChild("HideUIsBtn")
--[Variables]--
local tweenService = game:GetService("TweenService")
local mouse = game.Players.LocalPlayer:GetMouse()
local camera = workspace.CurrentCamera
local gui = script.Parent
local playBtn = gui:WaitForChild("Frame"):WaitForChild("PlayButton")
--[Menu Scene]--
local cameraPart = workspace:WaitForChild("MainMenuParts").ScreenCam
local characterPart = workspace.MainMenuParts.CharacterPart
--Camera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = cameraPart.CFrame
local playClicked = false
CurrentMusic.Playing = false
SmoothJazz:Play()
SmoothJazz.Playing = true
game:GetService("RunService").RenderStepped:Connect(function()
if not playClicked then
camera.CameraType = Enum.CameraType.Scriptable
local centreOfScreen = Vector2.new(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2)
local mouseDistanceFromCentre = Vector3.new((-mouse.X - centreOfScreen.X)/5000, (mouse.Y - centreOfScreen.Y)/5000, 0)
camera.CFrame = cameraPart.CFrame * CFrame.new(cameraPart.CFrame.LookVector + mouseDistanceFromCentre)
end
end)
--Character
local character = game.Players.LocalPlayer.Character
character:WaitForChild("Humanoid").WalkSpeed = 0
character.Humanoid.JumpHeight = 0
character.HumanoidRootPart.CFrame = characterPart.CFrame
playBtn.MouseButton1Click:Connect(function()
if not playClicked then
playClicked = true
SmoothJazz:Stop()
SmoothJazz.Playing = false
CurrentMusic.Playing = true
script.ClickSound:Play()
script.Parent:FindFirstChild("Frame").Visible = not script.Parent:FindFirstChild("Frame").Visible
camera.CameraType = Enum.CameraType.Custom
character.HumanoidRootPart.CFrame = workspace.SpawnLocation.CFrame + Vector3.new(0, 10, 0)
character.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
character.Humanoid.JumpHeight = game.StarterPlayer.CharacterJumpHeight
game.StarterGui:SetCore("ResetButtonCallback", true)
end
end)
local player = game.Players.LocalPlayer
local starterGui = game:WaitForChild("StarterGui")
local scriptParent = script.Parent
-- Function to disable all UIs except the script's parent
local function disableOtherUIs()
for _, gui in ipairs(starterGui:GetChildren()) do
if gui:IsA("ScreenGui") and gui ~= scriptParent then
gui.Enabled = false
end
end
end
-- Function to enable all UIs
local function enableAllUIs()
for _, gui in ipairs(starterGui:GetChildren()) do
if gui:IsA("ScreenGui") then
gui.Enabled = true
end
end
end
--player.CharacterRemoving:Connect(enableAllUIs) -- Enable UIs if the character is removed
SettingsBtn.MouseButton1Click:Connect(function()
InfowarnTxtLabel.Visible = true
InfowarnTxtLabel.Text = "Settings is a work in progress, check weekly for updates!"
task.wait(3)
InfowarnTxtLabel.Visible = false
end)
HideUIsBtn.MouseButton1Click:Connect(function()
InfowarnTxtLabel.Visible = true
InfowarnTxtLabel.Text = "Hiding UIs is a work in progress, check weekly for updates!"
task.wait(3)
InfowarnTxtLabel.Visible = false
if HideUIsBtn.Text == "Hide UIs" then
HideUIsBtn.Text = "Show UIs"
disableOtherUIs()
else
HideUIsBtn.Text = "Hide UIs"
enableAllUIs()
end
end)