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!