I've recently made a death effect, it a local script located inside StarterPlayerScripts and applies a ColorCorrectionEffect and Blur to the screen upon death. It works perfectly fine when for the first time I die, but after I die once it simply doesn't activate, any idea why?
Code:
local CCE = Instance.new("ColorCorrectionEffect", game.Lighting) CCE.Saturation = 0 CCE.Brightness = 0 CCE.Contrast = 0 local BE = Instance.new("BlurEffect", game.Lighting) BE.Size = 0 script.Parent.Parent.CharacterAdded:Wait() script.Parent.Parent.Character:WaitForChild("Humanoid").Died:Connect(function() for i = 1, 150 do wait(0.0125) BE.Size = BE.Size + 0.45 CCE.Saturation = CCE.Saturation - 0.0125 CCE.Brightness = CCE.Brightness - 0.00625 CCE.Contrast = CCE.Contrast - 0.00625 end wait(0.5) for i = 1, 75 do wait(0.0125) BE.Size = BE.Size - 0.9 CCE.Saturation = CCE.Saturation + 0.025 CCE.Brightness = CCE.Brightness + 0.0125 CCE.Contrast = CCE.Contrast + 0.0125 end CCE.Saturation = 0 CCE.Brightness = 0 CCE.Contrast = 0 BE.Size = 0 end)
local CCE = Instance.new("ColorCorrectionEffect", game.Lighting) CCE.Saturation = 0 CCE.Brightness = 0 CCE.Contrast = 0 local BE = Instance.new("BlurEffect", game.Lighting) BE.Size = 0 script.Parent.Parent.CharacterAdded:Connect(function(player) print("i entered") script.Parent.Parent.Character:WaitForChild("Humanoid").Died:Connect(function() print("I died") for i = 1, 150 do wait(0.0125) BE.Size = BE.Size + 0.45 CCE.Saturation = CCE.Saturation - 0.0125 CCE.Brightness = CCE.Brightness - 0.00625 CCE.Contrast = CCE.Contrast - 0.00625 end wait(0.5) for i = 1, 75 do wait(0.0125) BE.Size = BE.Size - 0.9 CCE.Saturation = CCE.Saturation + 0.025 CCE.Brightness = CCE.Brightness + 0.0125 CCE.Contrast = CCE.Contrast + 0.0125 end CCE.Saturation = 0 CCE.Brightness = 0 CCE.Contrast = 0 BE.Size = 0 end)
Here is the fundamental idea:
script.Parent.Parent.CharacterAdded:Connect(function(player) print("I spawned") script.Parent.Parent.Character:WaitForChild("Humanoid").Died:Connect(function() print("I died") end) end)
Good scripting