So i used this kit for a health gui and im trying to add a flashlight icon that disappear on death just like the health gui, but am having trouble making a script for the icon or adding it to the main Health gui. Heres Code v v v v v. the Part with Flashlight Gui is my Gui having Problem
while game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name)==nil do
game:GetService("RunService").RenderStepped:wait()
end
while game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name):FindFirstChild("Humanoid")==nil do
game:GetService("RunService").RenderStepped:wait()
end
script.Parent:WaitForChild("HPVisual")
script.Parent:WaitForChild("HPLabel")
script.Parent:WaitForChild("Critical")
script.Parent:WaitForChild("HPOutline")
script.Parent.Parent:WaitForChild("Background")
coroutine.resume(coroutine.create(function()
while true do
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
game:GetService("RunService").RenderStepped:wait()
if script.Parent.HPVisual.ImageColor3==Color3.new(1,0,0) then
if script.Parent.Critical.ImageTransparency==1 then
script.Parent.Critical.ImageTransparency=1
else
script.Parent.Critical.ImageTransparency=1
end
wait(0.15)
end
end
end))
game:GetService("RunService").RenderStepped:connect(function()
if game.Players.LocalPlayer.Character.Humanoid.Health<=0 then
script.Parent.Visible=false
script.Parent.Parent.Background.Visible=false
script.Parent.Flashlight_icon.Icon.Visible=false
script.Parent.Flashlight_icon.Background.Visible=false
end
script.Parent.Parent.Background.BackgroundColor3=game.Players.LocalPlayer.TeamColor.Color
if game.Players.LocalPlayer and game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:FindFirstChild("Humanoid") then
local percent=(math.floor(game.Players.LocalPlayer.Character.Humanoid.Health)/math.floor(game.Players.LocalPlayer.Character.Humanoid.MaxHealth))
script.Parent.HPVisual.ImageRectOffset=Vector2.new(0,((1-percent)*100))
script.Parent.HPVisual.Size=UDim2.new(1,0,percent,0)
script.Parent.HPVisual.Position=UDim2.new(0,0,1-percent,0)
script.Parent.HPLabel.Text=math.floor(game.Players.LocalPlayer.Character.Humanoid.Health)
if math.floor(game.Players.LocalPlayer.Character.Humanoid.Health)<2 and math.floor(game.Players.LocalPlayer.Character.Humanoid.Health)>0 then
script.Parent.HPLabel.Text=1
end
if percent<0.02 and percent>0 then
percent=0.01
end
if percent<=0.5 then
script.Parent.HPVisual.ImageColor3=Color3.new(1,0,0)
script.Parent.Critical.Visible=true
else
script.Parent.HPVisual.ImageColor3=Color3.new(1,1,1)
script.Parent.Critical.Visible=false
end
end
end)
