-
What do you want to achieve: I want to locally change the volume of sound(s) using a textbox and local script
-
What is the issue: I’m getting this issue where, after entering any value, the Sound’s volume is always becoming 10
-
What solutions have you tried so far: I’ve looked at this post and after some improvising worked completely fine yesterday until I return to work on my project and it’s all broken
This code took text from a textbox(button) and made it the volume of the sound, its input/100 because I wanted the volume in the text to be out of 100 (I.E type 50 and the sound volume is 0.5). Jukebox is a folder containing the sound (creb) It worked yesterday and it’s broken now
local button = script.Parent
local songs = {
game.SoundService.Jukebox.Creb;
}
local input = tonumber(button.Text)
function adjustSound(volume)
for _, object in next, songs do
if input<100 then
object.Volume = input/100
else
object.Volume = 0.5
button.Text = "50"
end
end
end
button.FocusLost:Connect(adjustSound)
I was getting an error (attempted to compare nil < 100) and I downsized the code to
local button = script.Parent
local songs = {
game.SoundService.Jukebox.Creb;
}
local input = tonumber(button.Text)
function adjustSound(volume)
for _, object in next, songs do
object.Volume = input
end
end
button.FocusLost:Connect(adjustSound)
The volume always becomes 10 and I just want the number in the text to be the same as the number in the Volume properties (locally)
P.S: This is my first DevForum post, literally, so if I make a mistake I’d highly appreciate one of you pointing it out and I’ll gladly fix it. Keep in mind that I’m trying my best.