Problems with changing volume

I am trying to do simple fade out effect on music after player leaves area

For some reason roblox can print v.volume but can’t change it. Here’s output:

  14:34:19.681  0.5 - Music:25
  14:34:19.681  0.5 - Music:11
  14:34:19.681  volume is not a valid member of Sound "Players.CEHATOP_PYCC.PlayerScripts.Music.Calm_Positive" - Music:12

Code:

local ZoneService = require(game:GetService("ReplicatedStorage").Zone)
local Areas = workspace:WaitForChild("AREAS")
local zone = ZoneService.new(Areas.Tension)

local MusicList = script:GetDescendants()

local CalmList = {script.Calm_Neutral, script.Calm_Positive}

local function SoftStop(music)
	repeat 
		print(music.volume)
		music.volume -= 0.1
		task.wait(0.1)
	until music.volume == 0
	music:Stop()
end

zone.playerEntered:Connect(function(player)
	CalmList[math.random(1, #CalmList)]:Play()
end)

zone.playerExited:Connect(function(player)
	for i, v in pairs(MusicList) do
		if v.IsPlaying == true then
			print(v.volume)
			SoftStop(v)
		end
	end
end)

Its Sound.Volume, you didn’t capitalize it

1 Like

Well to change the volume using a sound is:

--Rest of the scirpt is just logic
Sound.Volume = 1

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.