game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
wait(5)
for i = 0, 1, 0.1 do
script.Parent.BackgroundTransparency = i
wait(.1)
end
end)
end)
end)
Plus, you don’t need to say script.Parent.Visible = false at the end because when the background transparency reaches one, it alrdy invisible/
If this is on a Server Script, do please change it to a LocalScript and try this:
You’re able to easily access the Local Player by using game.Players.LocalPlayer
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Thingy = script.Parent
Humanoid.Died:Connect(function()
Thingy.Visible = true
wait(5)
for Loop = 1, 10 do
Thingy.BackgroundTransparency += .1
wait(.1)
end
Thingy.Visible = false
end)
As far as i can remember usually died event can also be fired when player is spawning so instead of using the Died event i would recommend to try and use Humanoid.Health = 0 instead
Fix spelling mistakes *i.e Parnet to Parent (script.Parnet.Visible = true)
Using Local Script inside the Death Message Frame
Code:
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1) -- Set the number to how long you want the fade to take
local plr = game.Players.LocalPlayer
local char = plr.Character
local humanoid = char:WaitForChild("Humanoid")
local deathFrame = script.Parent -- Getting death frame
deathFrame.Visible = false
humanoid.Died:Connect(function()
deathFrame.Visible = true
local tween = tweenService:Create(deathFrame, tweenInfo, {BackgroundTransparency = 0})
tween:Play()
wait(1.5) -- Tween length + Interval beteen the fade in and the disapering
deathFrame.Visible = false -- Resetting frame
deathFrame.BackgroundTransparency = 1
end)