However, as seen in the video, my problem is that it only tweens the first time the player has died. I checked it’s position afterwards, and that’s not the problem.
Here is the script I used:
local player = game.Players.LocalPlayer
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local image = script.Parent.Transition
local frame = script.Parent.Frame
hum.Died:Connect(function()
wait(1)
image:TweenSizeAndPosition(UDim2.new(0.033,0,0.057,0), UDim2.new(0.5,0,0.5,0), 1)
wait(1)
for i = 1,-0.05,-0.2 do
frame.BackgroundTransparency = i
wait()
end
wait(4)
for i = 0,1.05,0.2 do
frame.BackgroundTransparency = i
wait()
end
image:TweenSizeAndPosition(UDim2.new(1.2,0,2.1,0), UDim2.new(0.5,0,0.5,0), 1)
end)
Keep in mind, this ScreenGui does not reset on spawn.
Weird, it should. Try moving the humanoid variable in between CharacterAdded and Hum.Died
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
if humanoid then
humanoid.Died:Connect(function()
-- code
end)
end
end)
end)
I don’t think the PlayerAdded event will be called, So the CharacterAdded won’t be called either, Try this:
local Plr = game:GetService("Players").LocalPlayer;
local Char = Plr.Character or Plr.CharacterAdded:Wait();
local Hum = Char:WaitForChild("Humanoid");
--<Now Call The Character Added From The Already Defined Player
Plr.CharacterAdded:Connect(function(Character)
Char = Character;
Hum = Character:WaitForChild("Humanoid");
end)
Basically, since the code still runs after the player respawns (the gui doesn’t reset on spawn), I just cloned the local script and destroyed the original one.