Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't my Humanoid.Died firing?

I have this script;

 local TeleportService = game:GetService("TeleportService")

local gameID = 2094965912

local player = game.Players.LocalPlayer

local char = player.Character or player.CharacterAdded:Wait()

local fade = game.StarterGui.ScreenGui.Frame

  

char:WaitForChild("Humanoid").Died:Connect(function()

  

for i=1,10 do

fade.BackgroundTransparency = fade.BackgroundTransparency-0.1

wait(0.01)

end

  

wait(10)

  

TeleportService:Teleport(gameID)

  

end)

This is a local script located inside of ReplicatedFirst. What is is supposed to accomplish is wait for the local player Humanoid to die, then it will make a black screen fade in and after 10 seconds teleport the local player to another game. For some reason, nothing is happening. At all. Won't even fade, and the console is giving me nothing. Can anyone help?

2 comments

0

How is the player getting killed? When I tested this it worked. [local player = game.Players.LocalPlayer; local char = player.Character or player.CharacterAdded:Wait(); char:WaitForChild("Humanoid").Died:Connect(function() print('you died!!1'); end);]

0

are you sure that its not firing, it might b firing but the code insideit is wrong try adding a print inside and if it printed that means it fired

1 answer

First things first, let's restart.

  1. Add a Script to StarterCharacterScripts in StarterPlayer.
  2. Start listing what you need in terms of variables
local Players = game:GetService('Players')
local TeleportService = game:GetService('TeleportService')
local PlaceId = 2094965912
local Character = script.Parent -- this is because the script will be duplicated into the Character when the game runs
local Player = Players:GetPlayerFromCharacter(Character)
local PlayerGui = Player:WaitForChild('PlayerGui')
local Humanoid = Character.Humanoid
local Fade = PlayerGui.ScreenGui.Frame
  1. Now List your events
local Players = game:GetService('Players')
local TeleportService = game:GetService('TeleportService')
local PlaceId = 2094965912
local Character = script.Parent -- this is because the script will be duplicated into the Character when the game runs
local Player = Players:GetPlayerFromCharacter(Character)
local PlayerGui = Player:WaitForChild('PlayerGui')
local Humanoid = Character.Humanoid
local Fade = PlayerGui.ScreenGui.Frame

Humanoid.Died:Connect(function()

end)
  1. Now finish it with the commanding code
local Players = game:GetService('Players')
local TeleportService = game:GetService('TeleportService')
local PlaceId = 2094965912
local Character = script.Parent -- this is because the script will be duplicated into the Character when the game runs
local Player = Players:GetPlayerFromCharacter(Character)
local PlayerGui = Player:WaitForChild('PlayerGui')
local Humanoid = Character.Humanoid
local Fade = PlayerGui.ScreenGui.Frame

Humanoid.Died:Connect(function()
    for i = 1, 10 do
		wait()
		Fade.BackgroundTransparency = Fade.BackgroundTransparency - 0.1
	end
	wait(10)
	TeleportService:Teleport(PlaceId, Player) -- This line might need changing
end)

The thing about this script is each time you die it will be automatically reset.

Note: Copy pasting the code may not work. This is because I'm typing this raw with no tests. Simply do the work yourself.

Hope this helped!

Best of luck developer!

BlackOrange3343

This discussion is preserved as it was. New answers, comments, and votes are closed.