This LocalScript is inside a ScreenGui: (1298214499 is the sound id)
01 | local music = { "1298214499" , "1298214499" } |
02 | local sound = script.Parent.BGM |
03 | local muted = false |
04 |
05 | while true do |
06 | for i = 1 , #music do |
07 | sound.SoundId = "rbxassetid://" ..music [ i ] |
08 | sound:Play() |
09 | wait(sound.TimeLength) |
10 | end |
11 | end |
This LocalScript is inside a TextButton inside the ScreenGui the first LocalScript is in:
01 | local sound = script.Parent.Parent.BGM |
02 | local muted = false |
03 | script.Parent.MouseButton 1 Click:Connect( function () |
04 | if muted then |
05 | sound:Resume() |
06 | muted = false |
07 | script.Parent.Text = "Mute Music" |
08 | else |
09 | sound:Pause() |
10 | muted = true |
11 | script.Parent.Text = "Unmute Music" |
12 | end |
13 | end ) |
here is the game : https://web.roblox.com/games/929825495/Dice-o-mathy-BETA?refPageId=b621b278-c670-4274-a0ac-41a7522d1def
You have to use remote events ;)
I found an answer that works and does not need remote events! This is the new first LocalScript. Also the sound is now in workspace
01 | local music = game.Workspace.BGM |
02 |
03 | script.Parent.TextButton.MouseButton 1 Click:Connect( function () |
04 |
05 | if music.Volume = = 0 then |
06 |
07 | music.Volume = 2.5 |
08 |
09 | else |
10 |
11 | music.Volume = 0 |
12 | end |
13 | end ) |
This is the new second LocalScript.
01 | local sound = game.Workspace.BGM |
02 | local muted = false |
03 | script.Parent.MouseButton 1 Click:Connect( function () |
04 | if muted then |
05 | sound:Resume() |
06 | muted = false |
07 | script.Parent.Text = "Mute Music" |
08 | else |
09 | sound:Pause() |
10 | muted = true |
11 | script.Parent.Text = "Unmute Music" |
12 | end |
13 | end ) |