Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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()
0
This one is in a separate LocalScript, inside the Play button. Raven_Caedes 95 — 8y
Ad

Answer this question