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

Change Volume for Sound with script ?

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

Answer :

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

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