Hey there,
I’ve recently been working on a game, and I’ve created a custom death screen. What will happen is when the player dies, text will appear, and a background will fade in, while the text color turns red. Next, the text will change, as well as its color, and all GUI elements fade out, once the player has reset.
This all seems to be working completely fine, although it only works the first time I try it out. The GUI does not reset on spawn, and I’m quite certain that my script should work properly. Any help would be appreciated, thanks!
I have provided my script, as well as a screenshot of the GUI elements in the explorer. If anyone could help me, that would be greatly appreciated! Thank you,
— Spagheters
Gui Elements
Script
local TweenService = game:GetService("TweenService")
local Background = script.Parent.Frame
local Text = Background.Notice
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
local ColorGoal = {}
ColorGoal.TextColor3 = Color3.fromRGB(255, 35, 35)
local InBackgroundGoal = {}
InBackgroundGoal.BackgroundTransparency = 0
local OutBackgroundGoal = {}
OutBackgroundGoal.BackgroundTransparency = 1
local TextGoal = {}
TextGoal.TextTransparency = 1
local BackgroundInTween = TweenService:Create(Background, tweenInfo, InBackgroundGoal)
local BackgroundOutTween = TweenService:Create(Background, tweenInfo, OutBackgroundGoal)
local ColorTween = TweenService:Create(Text, tweenInfo, ColorGoal)
local TextTween = TweenService:Create(Text, tweenInfo, TextGoal)
local function typewrite(textlabel, text)
for i = 1, #text do
textlabel.Text = string.sub(text, 1, i)
wait(.05)
end
end
game.Players.LocalPlayer.Character:WaitForChild('Humanoid').Died:connect(function()
Text.TextColor3 = Color3.fromRGB(255, 255, 255)
Text.Text = ''
Text.TextTransparency = 0
Background.BackgroundTransparency = 1
wait(2)
ColorTween:Play()
typewrite(Text, 'Test Success = nil.')
BackgroundInTween:Play()
wait(2)
Text.TextColor3 = Color3.fromRGB(255, 255, 255)
typewrite(Text, 'Rebooting...')
wait(1)
TextTween:Play()
BackgroundOutTween:Play()
wait(2)
Text.TextColor3 = Color3.fromRGB(255, 255, 255)
Text.Text = ''
Text.TextTransparency = 0
Background.BackgroundTransparency = 1
end)