Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Game Menu works in Studio but doesn't on a game client?

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 answer

Continued.

local playButton = script.Parent
local MenuMusic = script.Parent.Parent.Parent.MenuMusic 

script.Parent.MouseButton1Click:connect(function()
	print("Clicked")
script.Parent.Parent.Parent.MenuMusic :Stop()

1 comment

0

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

This discussion is preserved as it was. New answers, comments, and votes are closed.