value.Changed:Connect function not working

So basically, I have a Local Script and a Number Value, both descendants of the Local Player’s Player Scripts. When the value changes, the Local Script is supposed to determine whether or not a song is playing based on what number the value holds. However, the script isn’t running at all when the value changes, it won’t even print anything (and yes, I made sure the value is changing in the first place). What’s going wrong here?

local future = game.Workspace:WaitForChild("TitleScreenMusic"):WaitForChild("Future")
local value = script.Parent.Parent:WaitForChild("Values"):WaitForChild("TitleScreenMusicPlaying")


--Code not triggering when value is changed:

value.Changed:Connect(function()
	print("Value changed")
	if value.Value == 0 then
		future.Playing = true
	else
		future.Volume = .65
		wait(.1)
		future.Volume = .55
		wait(.1)
		future.Volume = .45
		wait(.1)
		future.Volume = .35
		wait(.1)
		future.Volume = .25
		wait(.1)
		future.Volume = .15
		wait(.1)
		future.Volume = .05
		wait(.1)
		future.Volume = 0
		future.Playing = false
	end
end)

Try using this instead.

value:GetPropertyChangedSignal("Value"):Connect(function()
       print("Value changed")
	if value.Value == 0 then
		future.Playing = true
	else
      game.TweenService:Create(future, TweenInfo.new(), {Volume = 0})
end
end)
3 Likes