Death GUI Effect works once and never after

Hello there

Wrote a script that makes screen full dark and change some colorcorrection settings after dying, then reset it all after character spawn in. The problem is, gui doesn’t work as needed after first death.
I already know the option called “ResetOnSpawn” causing it but i dont really know how to fix this, as usual.

Script location:
image

Code:

local Player = game.Players.LocalPlayer
local Character = Player.Character

local Humanoid = Character:WaitForChild("Humanoid")
local TS = game:GetService("TweenService")

local curcc = game.Lighting.cc -- this is current colorcorrection instance, deadcc is like a preset for it
local deadcc = game.Lighting.ColorCorrections.Dead

local duration = 1

Humanoid.Died:Connect(function()
	TS:Create(curcc,TweenInfo.new(.5),{
		Brightness=deadcc.Brightness,
		Contrast=deadcc.Contrast,
		Saturation=deadcc.Saturation,
		TintColor=deadcc.TintColor
	}):Play()
	task.wait(2)
	TS:Create(script.Parent, TweenInfo.new(duration/2),{BackgroundTransparency=0}):Play()
	task.wait(game.Players.RespawnTime-2)
	curcc.Brightness = 0
	curcc.Contrast = 0
	curcc.Saturation = 0
	TS:Create(script.Parent, TweenInfo.new(duration),{BackgroundTransparency=1}):Play()
end)

Hope for yall brains

1 Like

You’re not resetting the TintColor

curcc.Brightness = 0
curcc.Contrast = 0
curcc.Saturation = 0
curcc.TintColor = Color3.fromRGB(255, 255, 255)
3 Likes

Could I have some clarification as to what you mean by “not working properly”? In what way does the gui stop working as needed after the first death?

I expected someone to say this so heres the video of what i mean:
robloxapp-20240308-1921060.wmv (1.3 MB)
If u notice, black screen doesnt appear after 2nd death of player, I blame “ResetOnSpawn” option causing this but dunno how to fix it

If the ResetOnSpawn property is the problem, I’d recommend turning it off. Scripting that property is likely not going to help you.

In the ScreenGui properties there is option to turn off ResetOnSpawn. Should hopefully solve your issue.

2 Likes