Adding a tween on my DeathGui

Hello devs! Im DragonDarkVader a Roblox Developer!

I need help with something i and my friend have been working on
Adding tween on my DeathGui

Code

game.Players.CharacterAutoLoads = false

game.Players.PlayerAdded:Connect(function(plr)
	print("plrAdded")
	local firstTime = true
	plr.CharacterAdded:Connect(function(char)
		print("CharAdded")
		local humanoid = char:WaitForChild("Humanoid")
		humanoid.Died:Connect(function()
			print("PlrDied")
			plr.PlayerGui.DeathGui.Enabled = true
			game.ReplicatedStorage.RemoteEvents.RemoveMouseIcon:FireClient(plr,false)
			wait(5)
			plr.PlayerGui.DeathGui.Enabled = false
		end)
	end)
	plr:LoadCharacter()
end)

Please someone help me add a tween on it, Like a Slowly appearing kind of tween.

local tweenService = game:GetService("TweenService")
local background = --the background of the deathgui
local tweenInfo = TweenInfo.new(4, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local tweenGoal = {BackgroundTransparency = 0}
local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
local tween = tweenService:Create(background, tweenInfo, tweenGoal)

humanoid.Died:Connect(function()
tween:Play()
end)

Where do i add that part? (character limit)

By the way…This is on ServerScriptService

i got an error of “local” in tweeninfo…

Sorry. My previous post won’t work. Instead, do something like this. Create a RemoteEvent called OnDeath and paste it in ReplicatedStorage. Then, do this:

The Death Script:

game.Players.CharacterAutoLoads = false

game.Players.PlayerAdded:Connect(function(plr)
	print("plrAdded")
	local firstTime = true
	plr.CharacterAdded:Connect(function(char)
		print("CharAdded")
		local humanoid = char:WaitForChild("Humanoid")
		humanoid.Died:Connect(function()
			print("PlrDied")
			plr.PlayerGui.DeathGui.Enabled = true
			game.ReplicatedStorage.OnDeath:FireClient(plr)
	game.ReplicatedStorage.RemoteEvents.RemoveMouseIcon:FireClient(plr,false)
			wait(5)
			plr.PlayerGui.DeathGui.Enabled = false
		end)
	end)
	plr:LoadCharacter()
end)

Add a LocalScript in StarterGui and write this inside:

local tweenService = game:GetService("TweenService")
local background = --the background of the deathgui
local tweenInfo = TweenInfo.new(4, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local tweenGoal = {BackgroundTransparency = 0}
local tween = tweenService:Create(background, tweenInfo, tweenGoal)

game.ReplicatedStorage.OnDeath.OnClientEvent:Connect(function()
tween:Play()
end)
1 Like

Same one, Error on “local” in tweeninfo

You should define the background variable as the background for your GUI

Like:

local background = script.Parent.Frame

Sadly, It does not work…If i reset. It will be visible…But in classic way, Not with tween

Sorry, I’ll have to answer you tomorrow with a more detailed script. Thank you for your time

1 Like

try this in a local script

local plr = game.Players.LocalPlayer

plr.char.HumanoidDied:Connect(function()
local tweenService = game:GetService("TweenService")
local background = --the background of the deathgui
local tweenInfo = TweenInfo.new(4, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local tweenGoal = {BackgroundTransparency = 0}
local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
local tween = tweenService:Create(background, tweenInfo, tweenGoal)
humanoid.Died:Connect(function()
plr.PlayerGui.DeathGui.Enabled = true
tween:Play()
plr.PlayerGui.DeathGui.Enabled = false
end)
end)
1 Like

Can you send me a screenshot of the DeathGui along with the explorer tab so I can see it’s components?