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

Change Volume for Sound with script ?

Asked by 3 years ago
Edited 3 years ago

Hello everyone !

I would need a little help, today I started to make a control system to change the music and the volume of the music, the only problem is when I change the volume instead to change the volume for me it changes the soundid.

Yet I made it clear that he must change the volume and not the soundid.

My current script :

    plr.Chatted:connect(function(msg)
        if string.sub((msg),1,9) == "/musicid " and admin or owner or canChangeMusic then

            local a = string.sub(msg,10)

            game.Workspace:FindFirstChild("Music").SoundId = "rbxassetid://"..a

            game.Workspace:FindFirstChild("Music").Volume = 0.1

            game.Workspace:FindFirstChild("Music").Playing = true

            game.Workspace:FindFirstChild("Music").TimePosition = 0

        elseif string.sub((msg),1,5) == "/vol " and admin or owner or canChangeMusic then

            local vol = string.sub(msg,6)

            local vol2 = tonumber(vol)

            game.Workspace:FindFirstChild("Music").Volume = vol2

        end
    end)

ps : I just noticed that after changing the soundid, I can turn the volume up or down with no problem, except that nothing works if I don't change the id before, and yes a random music starts when the server starts up.

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Answer :

if string.sub((msg),1,9) == "/musicid " and (admin or owner or canChangeMusic) then
Ad

Answer this question