I want to add music to my intro, please help

https://i.gyazo.com/94ec64751542f45a0ce71a43c4a33c9f.mp4
Here’s my game intro so far, and I would like a script that would play a song until the player clicks the continue button and loads into the game. I don’t know how to do this so any help would be appreciated.

Here’s the local script that closes the intro and spawns the player after finishing the intro

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
script.Parent.Parent.Parent.Enabled = false
Camera.CameraType = “Custom”
if Player.Character and Player.Character:FindFirstChild(“UpperTorso”) then
Player.Character.UpperTorso.CFrame = CFrame.new(53.72, 0.5, 64.18)
end
end)

You can use 3 ` to look your code a real code:

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
script.Parent.Parent.Parent.Enabled = false
Camera.CameraType = “Custom”
if Player.Character and Player.Character:FindFirstChild(“UpperTorso”) then
Player.Character.UpperTorso.CFrame = CFrame.new(53.72, 0.5, 64.18)
end
end)

This is quite easy, create the song and select it as a local:

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer

local Song = game.Workspace:FindFirstChild("Song")
Song:Play() --Will start playing

script.Parent.MouseButton1Click:connect(function()
script.Parent.Parent.Parent.Enabled = false
Camera.CameraType = “Custom”
if Player.Character and Player.Character:FindFirstChild(“UpperTorso”) then
Player.Character.UpperTorso.CFrame = CFrame.new(53.72, 0.5, 64.18)
end
end)

And now the part that you are asking for, Song stops playing when clicking continue:

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer

local Song = game.Workspace:FindFirstChild("Song")
Song:Play()

script.Parent.MouseButton1Click:connect(function()
script.Parent.Parent.Parent.Enabled = false
Song:Stop() --Song stops on clicking
Camera.CameraType = “Custom”
if Player.Character and Player.Character:FindFirstChild(“UpperTorso”) then
Player.Character.UpperTorso.CFrame = CFrame.new(53.72, 0.5, 64.18)
end
end)

I hope this code helps you! Also this thread’s category should be in Scripting Support! :+1:

Thanks for the advice and thanks for the time helping me with making a code!

Unfortunately I’m not very smart at scripting and never had experience creating a script for sound. Is it okay if I message you a place file with just the intro and have you figure out where to place the scripts for me? Sorry I’m a beginner scripter and don’t know what to do.

The script i gave you is the same that you have, just with lines that i have added:

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer

-----------------
local Song = game.Workspace:FindFirstChild("Song") --Finds "Song in workspace.
Song:Play() --Play Song.
-----------------

script.Parent.MouseButton1Click:connect(function()
script.Parent.Parent.Parent.Enabled = false

-----------------
Song:Stop()  --Stop song on clicking.
-----------------

Camera.CameraType = “Custom”
if Player.Character and Player.Character:FindFirstChild(“UpperTorso”) then
Player.Character.UpperTorso.CFrame = CFrame.new(53.72, 0.5, 64.18)
end
end)

I marked every line that i changed, and in this line:

local Song = game.Workspace:FindFirstChild("Song")

This part of FindFirstChild(“Song”) replace Song with the name of the music, and the music is set in workspace. (If you still don’t understand then you can give me the file)

1 Like

I tried again to do what you said. I re-pasted the code in my intro and put a lua script in workplace that plays the audio. I replaced ‘song’ in the quotations with the name of the music but nothing happened.

I don’t know what I did wrong. I’ll message you a new file of the working intro. Please add the music for me so I can learn from what I previously had.