Tweening Sound Not Tweening After Death But When Player Dies?

I am making a script that is suppose to tween sound to zero whenever player dies, and after they respawn it tweens back to normal volume.

This is a local script located in Starter Character Scripts.

The Blur/Rays/Screen Works just not the tween that comes after it, any idea whats wrong?

Blur.Enabled = false
	Rays.Enabled = false
	Screen.Enabled = false
	BlackOutline.Enabled = false
local DeadRemote = game.ReplicatedStorage.RemoteEvents.DeadEvent

local Player = game.Players.LocalPlayer
local Character = game.Workspace:WaitForChild(Player.Name)
local Humanoid = Character:WaitForChild("Humanoid")

local MainMusic = game.Players.LocalPlayer.PlayerGui.MainMusic

local ItemsFolder = game.Players.LocalPlayer.ItemsFolder

local generalTween = TweenInfo.new(
	.5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)


local TurnOffMainMusic = game:GetService("TweenService"):Create(MainMusic, generalTween, {Volume = 0})

Humanoid.Died:Connect(function()
	TurnOffMainMusic:Play()
	DeadRemote:FireServer()

	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)

	for i,v in pairs(ItemsFolder:GetChildren()) do
		if v:IsA("Tool") then
			v:Destroy()
		end
	end
end)

local BlackOutline = Player.PlayerGui.DeadScreen

local GameLighting = game.Lighting

local Blur = GameLighting.DeadBlur
local Rays = GameLighting.DeadRays
local Screen = GameLighting.DeadLighting

Humanoid.Died:Connect(function()

	for i, Prox in pairs(game.Workspace:GetChildren()) do
		if Prox:IsA("ProximityPrompt") then
			local Prox = Prox
			Prox.Enabled = true
		end
	end

	local StarterGui = game:GetService("StarterGui")
	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)

	local StarterGui = game:GetService("StarterGui")
	StarterGui:SetCore("TopbarEnabled", true)

	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)

	game.Players.LocalPlayer.PlayerGui.TopbarPlus.Enabled = true

	game.Lighting.ExposureCompensation = game.Lighting.ExposureCompensation == 0

	Blur.Enabled = true
	Rays.Enabled = true
	Screen.Enabled = true
	BlackOutline.Enabled = true
	
	task.wait(game.Players.RespawnTime)
	
	Blur.Enabled = false
	Rays.Enabled = false
	Screen.Enabled = false
	BlackOutline.Enabled = false
	
	game:GetService("TweenService"):Create(MainMusic, TweenInfo.new(.5), {Volume = 0.1}):Play()

end)

The script should go in StarterPlayerScripts. Since it’s in StarterCharacterScripts, it’s cloning the script to the character each time they spawn. The script gets deleted along with their character when they die, so it’s never getting to the tween part.

let me try this. max characters

This didnt work, I have no idea why though

You’ll have to change some things up for it to work. Use Player.CharacterAdded to detect each time the character spawns.

Alright I will try doing this, max characetrs

Maybe this will give you a starting point, I won’t be able to test it on my end though.

local DeadRemote = game.ReplicatedStorage.RemoteEvents.DeadEvent

local player = game.Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local MainMusic = PlayerGui:WaitForChild("MainMusic")
local ItemsFolder = player:WaitForChild("ItemsFolder")
local BlackOutline = PlayerGui.DeadScreen
local Blur = game.Lighting.DeadBlur
local Rays = game.Lighting.DeadRays
local Screen = game.Lighting.DeadLighting

local generalTween = TweenInfo.new(
	.5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local TurnOffMainMusic = game:GetService("TweenService"):Create(MainMusic, generalTween, {Volume = 0})
local TurnOnMainMusic = game:GetService("TweenService"):Create(MainMusic, TweenInfo.new(.5), {Volume = 0.1})



player.CharacterAdded:Connect(function(character)
	character:WaitForChild("Humanoid").Died:Connect(function()	
		
		TurnOffMainMusic:Play()
		DeadRemote:FireServer()

		for i, v in pairs(ItemsFolder:GetChildren()) do
			if v:IsA("Tool") then
				v:Destroy()
			end
		end

		Blur.Enabled = true
		Rays.Enabled = true
		Screen.Enabled = true
		BlackOutline.Enabled = true

		task.wait(game.Players.RespawnTime)

		Blur.Enabled = false
		Rays.Enabled = false
		Screen.Enabled = false
		BlackOutline.Enabled = false

		TurnOnMainMusic:Play()
		
	end)
end)

I tried this before and it didn’t work either. I just don’t get how Blur/Rays/Etc works just not the tween

Well, I just fixed numerous errors and cleaned your script up a lot. Just make sure it’s in StarterPlayerScripts and let me know if there are any errors in the output. Should be an easy fix.

I think I figured out the issue, I have the audio on default to 0, I did a test where a second before I respawn it tweens it back to normal, thing is when it did and i respawned it got set back to 0