Error With My Code

Hi Developers Yesterday I was making a mini system to play songs as I am learning Luau. To explain it better I will explain what it is about.

What is it about?

It’s about a UI with buttons that when you press one of them it plays a different song.
If you select a music but you want to listen to another one automatically when you press the other button the previous music stops and starts the one you selected (The ModuleScript can only be executed from the client and not in the server).

The mistake I’m here to tell you about is that when I open the panel and select the volume level the textlabel that says = “Current Volume is:” doesn’t change even though I put conditionals for the value I assigned to it

Code

local SoundService = game:GetService("SoundService")
local Button1 = script.Parent.Frame.ScrollingFrame:WaitForChild("Button1")
local Button2 = script.Parent.Frame.ScrollingFrame:WaitForChild("Button2")
local Button3 =script.Parent.Frame.ScrollingFrame:WaitForChild("Button3")
local button4 = script.Parent.Frame.ScrollingFrame:WaitForChild("Button4")
local button5 = script.Parent.Frame.ScrollingFrame:WaitForChild("Button5")
local other = script.Parent.desktop_mac
local sonidos = SoundService:FindFirstChild("Sonidos")
local frame = script.Parent.Frame




other.MouseButton1Click:Connect(function()
	
	frame.Visible = true 
	
end)




Button1.Text = sonidos["Desert War"].Name

Button2.Text = sonidos["Jazz Bass"].Name

Button3.Text = sonidos:WaitForChild("Live A Real Life").Name

button4.Text = sonidos:WaitForChild("Will To Win (A)").Name


Button1.MouseButton1Click:Connect(function()
	
	sonidos["Desert War"]:Play()
	
	sonidos["Jazz Bass"]:Stop()
	
	sonidos.Party:Stop()
	
	sonidos["Will To Win (A)"]:Stop()
	
	sonidos["djimboh - Imprints"]:Stop()
	
	sonidos["Ultimate Danger"]:Stop()
	
	sonidos["Party Song"]:Stop()
	
	sonidos["Live A Real Life"]:Stop()
	
	sonidos["Train Song"]:Stop()
	
sonidos["WRLD - Hang Up (feat. Savoi)"]:Stop()
	
	
	
end)



Button2.MouseButton1Click:Connect(function()
	
	sonidos["Jazz Bass"]:Play()
	
	sonidos.Party:Stop()

	sonidos["Will To Win (A)"]:Stop()

	sonidos["djimboh - Imprints"]:Stop()

	sonidos["Ultimate Danger"]:Stop()

	sonidos["Party Song"]:Stop()

	sonidos["Live A Real Life"]:Stop()

	sonidos["Train Song"]:Stop()

	sonidos["WRLD - Hang Up (feat. Savoi)"]:Stop()
	




	


	
	
	

	


end)




Button3.MouseButton1Click:Connect(function()
	
	sonidos["Live A Real Life"]:Play()
	
	sonidos["Jazz Bass"]:Stop()
sonidos["Desert War"]:Stop()
	sonidos.Party:Stop()

	sonidos["Will To Win (A)"]:Stop()

	sonidos["djimboh - Imprints"]:Stop()

	sonidos["Ultimate Danger"]:Stop()

	sonidos["Party Song"]:Stop()


	sonidos["Train Song"]:Stop()

	sonidos["WRLD - Hang Up (feat. Savoi)"]:Stop()
	
	
	

	






end)

button4.MouseButton1Click:Connect(function()
	sonidos["Desert War"]:Stop()
	sonidos["Jazz Bass"]:Stop()
	sonidos["Live A Real Life"]:Stop()
	sonidos["Will To Win (A)"]:Play()
	sonidos["Train Song"]:Stop()
	sonidos["Ultimate Danger"]:Stop()
	sonidos["WRLD - Hang Up (feat. Savoi)"]:Stop()
	sonidos["Party Song"]:Stop()
	sonidos.Party:Stop()
	
	
	
end)


button5.MouseButton1Click:Connect(function()
	
	frame.Visible = false 
end)




local color1 = Color3.fromRGB(255, 85, 0)

local color2 = Color3.fromRGB(255, 255, 0)

Button1.BackgroundColor3 = color1
Button1.TextColor3 = color2
Button2.BackgroundColor3 = color1
Button2.TextColor3 = color2

Button3.BackgroundColor3 = color1

Button3.TextColor3 = color2


button4.BackgroundColor3 = color1

button4.TextColor3  = color2





local  button6 = script.Parent.Frame.ScrollingFrame:WaitForChild("Button6")
local button7 = script.Parent.Frame.ScrollingFrame:WaitForChild("Button7")
local button8 = script.Parent.Frame.ScrollingFrame:WaitForChild("Button8")
local button9 = script.Parent.Frame.ScrollingFrame:WaitForChild("Button9")
local button10 = script.Parent.Frame.ScrollingFrame:WaitForChild("Button10")
local button11 = script.Parent.Frame.ScrollingFrame:WaitForChild("Button11")



button6.MouseButton1Click:Connect(function()
sonidos["Ultimate Danger"]:Stop()
	sonidos["Party Song"]:Play()
	
	sonidos["djimboh - Imprints"]:Stop()
	
	sonidos.Party:Stop()
	sonidos["djimboh - Imprints"]:Stop()
	sonidos["WRLD - Hang Up (feat. Savoi)"]:Stop()
	sonidos["Will To Win (A)"]:Stop()
	sonidos["Desert War"]:Stop()



	sonidos["Ultimate Danger"]:Stop()
	sonidos["Live A Real Life"]:Stop()


	sonidos["Jazz Bass"]:Stop()

	sonidos["Train Song"]:Stop()

	sonidos["Jazz Bass"]:Stop()

	sonidos["Train Song"]:Stop()

	

	





	

	


	
end)




button7.MouseButton1Click:Connect(function()
	
	
	sonidos.Party:Play()
	
	sonidos["Party Song"]:Stop()
	
	sonidos["WRLD - Hang Up (feat. Savoi)"]:Stop()
	
	sonidos["djimboh - Imprints"]:Stop()
	sonidos["WRLD - Hang Up (feat. Savoi)"]:Stop()
	sonidos["Will To Win (A)"]:Stop()
	sonidos["Desert War"]:Stop()


	sonidos["Party Song"]:Stop()

	sonidos["Live A Real Life"]:Stop()


	sonidos["Jazz Bass"]:Stop()

	sonidos["Train Song"]:Stop()
end)



button8.MouseButton1Click:Connect(function()
	
	sonidos["djimboh - Imprints"]:Play()
	sonidos["WRLD - Hang Up (feat. Savoi)"]:Stop()
	sonidos["Will To Win (A)"]:Stop()
	sonidos["Desert War"]:Stop()
	sonidos.Party:Stop()
	
	sonidos["Party Song"]:Stop()
	
	sonidos["Live A Real Life"]:Stop()
	
	
	sonidos["Jazz Bass"]:Stop()
	
	sonidos["Train Song"]:Stop()
	
	sonidos["Ultimate Danger"]:Stop()
	
end)





button9.MouseButton1Click:Connect(function()
	
	sonidos["Train Song"]:Play()
	sonidos["djimboh - Imprints"]:Stop()
	sonidos["WRLD - Hang Up (feat. Savoi)"]:Stop()
	sonidos["Will To Win (A)"]:Stop()
	sonidos["Desert War"]:Stop()
	sonidos.Party:Stop()

	sonidos["Party Song"]:Stop()

	sonidos["Live A Real Life"]:Stop()


	sonidos["Jazz Bass"]:Stop()
	
	sonidos["Ultimate Danger"]:Stop()
end)

button10.MouseButton1Click:Connect(function()
	
	sonidos["WRLD - Hang Up (feat. Savoi)"]:Play()
	
	sonidos["Train Song"]:Stop()
	sonidos["djimboh - Imprints"]:Stop()

	sonidos["Will To Win (A)"]:Stop()
	sonidos["Desert War"]:Stop()
	sonidos.Party:Stop()

	sonidos["Party Song"]:Stop()

	sonidos["Live A Real Life"]:Stop()


	sonidos["Jazz Bass"]:Stop()
	
	
	sonidos["Ultimate Danger"]:Stop()
	
	
	
end)




button11.MouseButton1Click:Connect(function()
	
	sonidos["Ultimate Danger"]:Play()
	
	
	sonidos["Jazz Bass"]:Stop()
	
	sonidos["Desert War"]:Stop()
	
	sonidos["Will To Win (A)"]:Stop()
	
	sonidos["djimboh - Imprints"]:Stop()
	
	sonidos.Party:Stop()
	
	sonidos["Party Song"]:Stop()
	
	sonidos["WRLD - Hang Up (feat. Savoi)"]:Stop()
	
	sonidos["Train Song"]:Stop()
	
	

	
end)
	

button6.Text =  sonidos["Party Song"].Name

button7.Text = sonidos.Party.Name

button8.Text = sonidos["djimboh - Imprints"].Name

button9.Text = sonidos["Train Song"].Name

button10.Text =  sonidos["WRLD - Hang Up (feat. Savoi)"].Name

button11.Text = sonidos["Ultimate Danger"].Name
	
	

button6.BackgroundColor3 =  color1
button7.BackgroundColor3 = color1
button8.BackgroundColor3 = color1
button9.BackgroundColor3 = color1
button10.BackgroundColor3 = color1
button11.BackgroundColor3 = color1

button6.TextColor3 = color2
button7.TextColor3 = color2
button8.TextColor3 = color2
button9.TextColor3 = color2
button10.TextColor3 = color2
button11.TextColor3  = color2


local controller = script.Parent.Controller
local Control = SoundService.Control
local low = controller.Low
local medium = controller.Medium
local high = controller.High
local Current = controller["Current Volume"]
local mute = controller.Mute
local radio = script.Parent.radio

radio.MouseButton1Click:Connect(function()
	
	controller.Visible = true
controller.Close.MouseButton1Click:Connect(function()
	
	controller.Visible = false
	
	
	
	
end)


low.MouseButton1Click:Connect(function()
	
	
	Control.Volume = 0.576
end)
	

medium.MouseButton1Click:Connect(function()
	
	
	Control.Volume = 1.6
end)



high.MouseButton1Click:Connect(function()
	
	Control.Volume = 10
	
	
	
end)
	
mute.MouseButton1Click:Connect(function()
	
	Control.Volume = 0
end)
if Control.Volume == 10 then
	
	Current.Text = "Current Volume is : 10"
	
	
end

if Control.Volume == 0.576 then
	
	Current.Text ="Current Volume is: 0.576"

	
end


if Control.Volume == 1.6 then
	Current.Text ="Current Volume is: 1.6"
	

	

end

if Control.Volume == 0 then
	
	Current.Text = "Current Volume is: 0"

	

end
return frame.Visible






Note: The code is a ModuleScript, not a common LocalScript.

This is what mainly fails me,The whole issue revolves around this problem

From what I’m seeing, you’re using 2 different sound groups.

local sonidos = SoundService:FindFirstChild("Sonidos")
local Control = SoundService.Control

Are you changing the volume property on the correct sound group? (Assuming that both are sound groups)

Sonidos Is a Folder With Sounds

Gotcha! Are you sure that the SoundGroup property on the sounds are routed to the “Control” sound group?

image

control is a Sound Group

This sound group has its property changed

Yes Check each of the sounds :grinning:

Captura de pantalla 2023-02-21 152349

Hold on, I might have read your initial post wrong. Are you asking how to update the text every time the volume changes? If so you can use :GetPropertyChangedSignal()!

In your case, it would be like this:

Control:GetPropertyChangedSignal("Volume"):Connect(function()
    --<< Volume has updated >>--
    Current.Text = "Current volume is : " .. Control.Volume
end)

So I was wrong, thank you for your help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.