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

Why isnt my volume table chaning the text?

so i want to make a volume adjuster but my textlabel wont set to what i want it to set to. I have tried to do this without the table but it just put them with extra numbers i did not want.

while wait() do
	script.Parent.Text = Music.Volume
	
	if Music.Volume == 0 then
		script.Parent.Text = "Volime: 0"
	elseif Music.Volume == 0.1 then
		script.Parent.Text = "Volime: 0.1"
	elseif Music.Volume == 0.2 then
		script.Parent.Text = "Volime: 0.2"
	elseif Music.Volume == 0.3 then
		script.Parent.Text = "Volime: 0.3"
	elseif Music.Volume == 0.4 then
		script.Parent.Text = "Volime: 0.4"
	elseif Music.Volume == 0.5 then
		script.Parent.Text = "Volime: 0.5"
	elseif Music.Volume == 0.6 then
		script.Parent.Text = "Volime: 0.6"
	elseif Music.Volume == 0.7 then
		script.Parent.Text = "Volime: 0.7"
	elseif Music.Volume == 0.8 then
		script.Parent.Text = "Volime: 0.8"
	elseif Music.Volume == 0.9 then
		script.Parent.Text = "Volime: 0.9"
	elseif Music.Volume == 1 then
		script.Parent.Text = "Volime: 1"	
	end
end

can someone please explain what im doing wrong here?

2 answers

Nooo!!! Use a table for this man. localize your music volume, and make a for loop.

if (Music.Volume >=0 and Music.Volume <= 1) and Music.Volume % 0.1 == 0 then
  script.Parent.Text = "Volume: "..tostring(Music.Volume)
end

This above will do the conversion for you and will keep track of that stuff for you. It will also convert text.

3 comments

0

lmao 27 line -> 3 lines

0

eh /shrug

0

if this helped make sure to upvote and accept :D

If Music.Volume is a NumberValue, listen to its Changed event for maximum efficiency (instead of running code periodically):

local label = script.Parent.Text
Music.Volume.Changed:Connect(function()
	label.Text = "Volume: " .. Music.Volume.Value
end)

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