I have a MenuGui that should be visible to all players when they join the game. However, it only appears for the first player who joins. Any players who join afterward don’t see the GUI at all.
What I’ve Checked
MenuGuiis located insideStarterGui, so it should be cloned into each player’sPlayerGuion join.- I checked all existing scripts in the game.
- The only script that references or handles the
MenuGuiis a script calledMenuHandler. - None of the scripts are explicitly destroying or hiding
MenuGui.
Behavior
- First player joins:
MenuGuiworks fine. - Subsequent players:
MenuGuiis missing.
Script:
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Camera = workspace.CurrentCamera
local player = Players.LocalPlayer
local MainMenuGui = script.Parent
local deployButton = MainMenuGui:WaitForChild("DeployButton")
local blackOverlay = MainMenuGui:WaitForChild("Black")
local music = MainMenuGui:WaitForChild("GameMusic")
local gameGui = player:WaitForChild("PlayerGui"):WaitForChild("GameGui")
local menuCam = workspace:WaitForChild("MenuCam")
local function Setup()
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = menuCam.CFrame
if MainMenuGui then
MainMenuGui.Enabled = true
end
end
local ReturnToMenuEvent = ReplicatedStorage:FindFirstChild("Misc") and ReplicatedStorage.Misc:FindFirstChild("Events") and ReplicatedStorage.Misc.Events:FindFirstChild("ReturnToMenu")
local TeleportMe = ReplicatedStorage.Misc and ReplicatedStorage.Misc.Events and ReplicatedStorage.Misc.Events:FindFirstChild("TeleportMe")
local inMenu = true
local transitioning = false
local function fade(toTransparency, time)
return TweenService:Create(blackOverlay, TweenInfo.new(time), {Transparency = toTransparency})
end
MainMenuGui.DeployButton.Activated:Connect(function()
if transitioning then return end
transitioning = true
fade(0, 1):Play()
TweenService:Create(music, TweenInfo.new(1), {Volume = 0}):Play()
task.wait(1.5)
music:Stop()
MainMenuGui.Enabled = false
gameGui.Enabled = true
Camera.CameraType = Enum.CameraType.Custom
TeleportMe:FireServer(true)
fade(1, 1):Play()
inMenu = false
transitioning = false
end)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed or inMenu then return end
if input.KeyCode == Enum.KeyCode.M then
inMenu = true
ReturnToMenuEvent:FireServer()
TeleportMe(false)
Setup()
gameGui.Enabled = false
music.Volume = 1
music:Play()
end
end)
Setup()
