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.
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)
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