Why isn't my gui appearing again after the player resets or dies?
Alright, so I have this health gui local script and it has the extra ability to identify the player's team by changing it's frame color for example to red or blue and the problem i'm having that it's not appearing when the player resets and there's no even a single error appearing in Output that I can idenfity it's problem, please help any kind of assistance would be appreciated.
01 | while game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name) = = nil do |
02 | game:GetService( "RunService" ).RenderStepped:wait() |
05 | while game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name):FindFirstChild( "Humanoid" ) = = nil do |
06 | game:GetService( "RunService" ).RenderStepped:wait() |
13 | script.Parent:WaitForChild( "HPVisual" ) |
14 | script.Parent:WaitForChild( "HPLabel" ) |
15 | script.Parent:WaitForChild( "Critical" ) |
16 | script.Parent:WaitForChild( "HPOutline" ) |
17 | script.Parent.Parent:WaitForChild( "Background" ) |
18 | coroutine.resume(coroutine.create( function () |
20 | game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false ) |
21 | game:GetService( "RunService" ).RenderStepped:wait() |
22 | if script.Parent.HPVisual.ImageColor 3 = = Color 3. new( 1 , 0 , 0 ) then |
23 | if script.Parent.Critical.ImageTransparency = = 1 then |
24 | script.Parent.Critical.ImageTransparency = 0 |
26 | script.Parent.Critical.ImageTransparency = 1 |
32 | game:GetService( "RunService" ).RenderStepped:connect( function () |
33 | if game.Players.LocalPlayer.Character.Humanoid.Health< = 0 then |
34 | script.Parent.Visible = false |
35 | script.Parent.Parent.Background.Visible = false |
37 | script.Parent.Parent.Background.BackgroundColor 3 = game.Players.LocalPlayer.TeamColor.Color |
38 | if game.Players.LocalPlayer and game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:FindFirstChild( "Humanoid" ) then |
39 | local percent = (math.floor(game.Players.LocalPlayer.Character.Humanoid.Health)/math.floor(game.Players.LocalPlayer.Character.Humanoid.MaxHealth)) |
40 | script.Parent.HPVisual.ImageRectOffset = Vector 2. new( 0 ,(( 1 -percent)* 100 )) |
41 | script.Parent.HPVisual.Size = UDim 2. new( 1 , 0 ,percent, 0 ) |
42 | script.Parent.HPVisual.Position = UDim 2. new( 0 , 0 , 1 -percent, 0 ) |
43 | script.Parent.HPLabel.Text = math.floor(game.Players.LocalPlayer.Character.Humanoid.Health) |
44 | if math.floor(game.Players.LocalPlayer.Character.Humanoid.Health)< 2 and math.floor(game.Players.LocalPlayer.Character.Humanoid.Health)> 0 then |
45 | script.Parent.HPLabel.Text = 1 |
47 | if percent< 0.02 and percent> 0 then |
51 | script.Parent.HPVisual.ImageColor 3 = Color 3. new( 1 , 0 , 0 ) |
52 | script.Parent.Critical.Visible = true |
54 | script.Parent.HPVisual.ImageColor 3 = Color 3. new( 1 , 1 , 1 ) |
55 | script.Parent.Critical.Visible = false |