Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why isnt my volume table chaning the text?

Asked by 4 years ago

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.

01while wait() do
02    script.Parent.Text = Music.Volume
03 
04    if Music.Volume == 0 then
05        script.Parent.Text = "Volime: 0"
06    elseif Music.Volume == 0.1 then
07        script.Parent.Text = "Volime: 0.1"
08    elseif Music.Volume == 0.2 then
09        script.Parent.Text = "Volime: 0.2"
10    elseif Music.Volume == 0.3 then
11        script.Parent.Text = "Volime: 0.3"
12    elseif Music.Volume == 0.4 then
13        script.Parent.Text = "Volime: 0.4"
14    elseif Music.Volume == 0.5 then
15        script.Parent.Text = "Volime: 0.5"
View all 27 lines...

can someone please explain what im doing wrong here?

2 answers

Log in to vote
0
Answered by 4 years ago

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

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

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

0
lmao 27 line -> 3 lines WideSteal321 773 — 4y
0
eh /shrug Nicholas1088 169 — 4y
0
if this helped make sure to upvote and accept :D Nicholas1088 169 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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

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

Answer this question