Tweening upon death and respawn not working, no displayed errors

I’m making a script that fades the screen to black when you die, and then fades back out when you respawn, for a nice clean transition upon death. Unfortunately, I’m having trouble making it work. I reached the point where I’m no longer receiving any errors, but it still doesn’t work.

I have a script in ServerScriptService that fires to “Fade” event located in ReplicatedStorage. The local script embedded in the GUI itself does the rest of the work.

ServerScriptService – Regular Script

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		game.ReplicatedStorage.Fade:FireClient(player, "unfade")
		char:WaitForChild('Humanoid').Died:Connect(function()
			game.ReplicatedStorage.Fade:FireClient(player, "fade")
		end)
	end)
end)

StarterGui - Local Script

local player = game.Players.LocalPlayer
local TweenService = game:GetService("TweenService")

local fade = script.Parent.fade
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

game.ReplicatedStorage:WaitForChild("Fade").OnClientEvent:Connect(function(option)
	if option == "fade" then	
		local Tween = TweenService:Create(fade, tweenInfo, {BackgroundTransparency = 0})
		
	else
		local Tween2 = TweenService:Create(fade, tweenInfo, {BackgroundTransparency = 1})
	end
end)

Any help is greatly appreciated, thanks!

You don’t seem to be playing the tweens, rather just creating them only, use the :Play() function on your tween variables

Tween:Play()
Tween2:Play()
1 Like

Ah dang, I’ve dun goofed :joy:. Added the play functions, but only the death fade works. When you respawn, there’s no fade. I don’t want to keep for too long, but any ideas?

Hmm, could be something to do with the gui itself, does the GUI have ResetOnSpawn enabled? If so, try disabling it

1 Like

With a little tweaking, that did the trick. Thanks for the help!

1 Like