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

How do I put an audio into a loading screen then make it stop when the player clicks play?

I have a screen that has the game logo and theres a "Play" button. How do I add music then make the music stop when the player clicks Play? Thanks!

1 answer

You can just put a sound into a ScreenGui(or anywhere else in the PlayerGui but preferably in a ScreenGui for easier access).

Put this in a ScreenGui in a LocalScript. Make sure there's a sound in the ScreenGui as well as a TextButton.

local gui = script.Parent
local sound = gui:WaitForChild("Sound")
local button = gui:WaitForChild("TextButton")

sound:Play()

button.MouseButton1Click:Connect(function()
	sound:Stop()
end)

4 comments

1

Thank you so much for the reply! I put a sound then that script in a local script but it's still the same as before. The audio plays and doesn't stop. Is there anything I should rename in that script? The Play is actually an ImageButton so I changed TextButton to ImageButton but it still wont work.

0

When you changed the text that says "TextButton", did you change it to the name of the ImageButton or just ImageButton? Or is the name already ImageButton?

0

The image button is named Play so I changed TextButton to Play.

0

You can just use my answer and edit somethings to your preference. https://scriptinghelpers.org/questions/102160/why-wont-my-while-music-looploop-again

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