How to have a menu-play button play a song & display lyrics once pressed

I’ve had trouble trying to come up with some sort of script when a menu playbutton is pressed to play a song with lyrics showing up. I’ve looked all over the forums, youtube and even comments sections and I’m yet to find it. An example of the idea is the game “It’s Been So Long” where at the end is a replay button (I can figure that out easily) however I can’t seem to figure out what I should do, so I resorted here.

Screenshot (655)
Here’s the menu screen

Screenshot (656)
The files/scripts I have and where they’re placed

Screenshot (657)
The lyric screen code (not sure if I need to add anything above it like a wait or if statement

Screenshot (658)
Finally, the code for a play-sound script I got off of a youtube vid, however it didn’t seem to work

Sorry for it being so lengthy, but I hope there’s a solution out there so that other people with the same idea can have their question answered

2 Likes

Have you uploaded the song on roblox yet? Because in order to play songs, they need to be in roblox’s library which you can upload to through Login. Once you have done that you can just do:

local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://ID of the audio in the website" --Or you can just set the id on a sound you already made before running.
sound:Play()

I grabbed the song from the toolbox, but I’ll definitely try that script. Btw, where would I put this code?

1 Like

A while back, I was watching a tutorial from AlvinBlox on changing a game’s status, and I found out that a way to change text whilst having it shown in game is by assigning the text label’s text as whatever value is put in a StringValue every time.

This can easily be done by doing
TextLabel.Text = StringValue.Value

Of course, this still doesn’t display new text when it’s changed yet, which is why GetPropertyChangedSignal(string property) comes into play. GetPropertyChangedSignal(string property) is a function that detects if a given/chosen property is changed. In order to utilize this, you simply need to put this in an event.

StringValue.GetPropertyChangedSignal(“Value”):Connect(function()

Assign the StringValue’s string to TextLabel again after that, like the first line of code I wrote, and it should work.

Sorry if it was a bit difficult to understand, I had a bit of a problem trying to think up how to construct my sentences, and this is merely from my poor memory, so it might not work if I’m wrong.

Edit: I did some research and found out that the actual way to incorporate GetPropertyChangedSignal(string property) into an event is by doing this:

StringValue:GetPropertyChangedSignal(string property):Connect(function()

You can place it just after the MouseButton1 function in a while loop which will play it until the player has pressed play.

For instance:

local playButton = script.Parent.PlayButton

local mainFrame = script.Parent

local debounce = false

playButton.MouseButton1Click:Connect(function()

mainFrame.Visible = false

debounce = true

end)

while debounce == false do

local sound = Instance.new("Sound", game.Workspace)

sound.SoundId = "rbxassetid://ID of the audio in the website" --Or you can just set the id on a sound you already made before running.

sound:Play()

end

Thank you! I’ll definitely try this out and see if it works. Didn’t think Alvin made a video on this at all, but thanks again for clearing a lot up!

Here’s the video on game status.

In this video, he actually uses StringValue.Changed, so try that if GetPropertyChangedSignal(string property) doesn’t work.

Edit: Also if GetPropertyChangedSignal(string property) didn’t work, then I recommend checking my edit on my original post which corrects what I did. Sorry if my mistake made you get sidetracked :sweat:

So the script just broke the game entirely, could you give me more of a clear area of where I should put the code?

Hey! So I tried that out and maybe I’m doing something completely wrong–as I am a new scripter–but I don’t see how this could allow me to display the gui for the lyrics and have the song play at the same time once “play” is pressed. Maybe I’m not understanding it well but who knows

Also, you’re not sidetracking me at all! It’s totally ok lol

Basically, you need to create a script and write out a function that activates when the button is pressed. This function should play both the sound and start changing the StatusValue.Value. In case you didn’t know, it doesn’t matter which order those things should happen, so you can play the sound first, or even change the value first.

Meanwhile, you have a StringValue inserted in the ReplicatedStorage (or anywhere, it doesn’t matter) that has a blank value, so the text is shown as nothing, and therefore, the lyrics aren’t visible yet.

Now, you need to make a script that uses :GetPropertyChangedSignal(“”) and :Connect() or .Changed and :Connect() to reset the text shown into what the StatusValue’s current value is currently, since the text isn’t going to automatically change into the new value unless you help it by resetting the text to the value.

Again, this can be done with:

TextLabel.Text = StatusValue.Value
(Please keep in mind that this isn’t how you should fully define TextLabel and StatusValue, I’m just giving an example)

In case you are not sure how to play sound into the game, just simply define your Sound as a variable, and use :Play()

This is all the information you need to know in order to create the game.

List of functions and events you need to use:

:Connect()

Sound:Play()

:GetPropertyChangedSignal(“NameOfProperty”)

.MouseButton1Click (for the button)

1 Like

tysm! This clears it up a LOT!