I've ran into this issue numerous times when I make something that involves using PlayerAdded. The script is inside a GUI, and is a LocalScript.
local Players = game:GetService("Players")
function onPlayerAdded(player)
local mainMenu = script.Parent
mainMenu.Name = "Main Menu"
local frame = mainMenu:WaitForChild("Frame")
frame.Parent = mainMenu
frame.Visible = true
end
Players.PlayerAdded:connect(onPlayerAdded)
for _,player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
--Plays menu music
local MenuMusic= script.Parent.MenuMusic
MenuMusic:Play()
EDIT: I fixed it by replacing various lines with others.

1 comment
This one is in a separate LocalScript, inside the Play button.