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 3 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.

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

Log in to vote
0
Answered by 3 years ago

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.

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

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)

Answer this question