You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I am doing whenever the Player is under 30 health, there would be a red screen.
What is the issue? It does not work.
What solutions have you tried so far? I had look for many post, I had unable to find one.
local Player = game.Players.LocalPlayer
local UI = Player.PlayerGui.status
local Frame = UI.Frame
local Character = Player.Character
local Humanoid = Character:WaitForChild('Humanoid')
if Humanoid.Health <= 30 then
Frame.BackgroundTransparency = 0.8
UI.Enabled = true
print("Successful!")
else
print("Something went wrong.")
end
if Humanoid.Health == 0 then
Frame.BackgroundTransparency = 0
wait(3)
UI.Enabled = false
print("Successful!")
else
print("Something went wrong.")
end
-- This script is run in Localscript
local Players = game:GetService("Players")
local Player = Players.LocalPlayer or Players.PlayerAdded:Wait()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild('Humanoid')
local PlayerGui = Player:WaitForChild("PlayerGui")
local UI = PlayerGui:WaitForChild("status")
local Frame = UI:WaitForChild("Frame")
Humanoid.HealthChanged:Connect(function(NewHealth)
if NewHealth > 0 and NewHealth <= 30 then
Frame.BackgroundTransparency = 0.8
UI.Enabled = true
elseif NewHealth <= 0 then
Frame.BackgroundTransparency = 0
task.wait(3)
UI.Enabled = false
end
end)
local Players = game:GetService("Players")
local Player = Players.LocalPlayer or Players.PlayerAdded:Wait()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild('Humanoid')
local PlayerGui = Player:WaitForChild("PlayerGui")
local UI = PlayerGui:WaitForChild("status")
local Frame = UI:WaitForChild("Frame")
Humanoid.HealthChanged:Connect(function(NewHealth)
if NewHealth > 0 and NewHealth <= 30 then
Frame.BackgroundTransparency = 0.8
UI.Enabled = true
end
end)
Humanoid.Died:Connect(function()
Frame.BackgroundTransparency = 0
task.wait(3)
UI.Enabled = false
end)
local Players = game:GetService("Players")
local Player = Players.LocalPlayer or Players.PlayerAdded:Wait()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild('Humanoid')
local PlayerGui = Player:WaitForChild("PlayerGui")
local UI = PlayerGui:WaitForChild("status")
local Frame = UI:WaitForChild("Frame")
Humanoid.HealthChanged:Connect(function(NewHealth)
if NewHealth > 30 then
Frame.BackgroundTransparency = 1
UI.Enabled = false
end
end)
Humanoid.HealthChanged:Connect(function(NewHealth)
if NewHealth > 0 and NewHealth <= 30 then
Frame.BackgroundTransparency = 0.8
UI.Enabled = true
end
end)
Humanoid.Died:Connect(function()
Frame.BackgroundTransparency = 0
task.wait(3)
UI.Enabled = false
end)