Okay so basically i have a little GameHandler localscript for startercharacter, it functions right and perfectly however it does not look very clean and organized. Any ideas on how i can clean it up?
local HB = game.ReplicatedStorage.HB
local TweenService = game:GetService("TweenService")
local Gui = player.PlayerGui:WaitForChild("MainUI"):WaitForChild("BloodImage")
game.ReplicatedStorage.Events.UnDown.OnClientEvent:Connect(function() -- Undown effect
if Humanoid.Health > 0 then
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
warn("Debugging")
TweenService:Create(
Gui,
TweenInfo.new(10),
{ImageTransparency = 0.5 + (Humanoid.Health / Humanoid.MaxHealth)}
):Play()
end
end)
script.Parent.Events.IsDowned.OnClientEvent:Connect(function(VAL) -- Downed effect
if VAL == "ON" then
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
Gui.ImageTransparency = 0.4
game:GetService("TweenService"):Create(game.Lighting.Blurred, TweenInfo.new(1), {Size = 15}):Play()
df.Enabled = true
HB:Play()
if shift.Enabled == true then
shift.Enabled = false
end
game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
print("ON")
elseif VAL == "OFF" then
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
--Gui.ImageTransparency = 1
if shift.Enabled == false then
shift.Enabled = true
end
df.Enabled = false
game:GetService("TweenService"):Create(game.Lighting.Blurred, TweenInfo.new(1), {Size = 0}):Play()
game:GetService("StarterGui"):SetCore("ResetButtonCallback", true)
if Humanoid.Parent:FindFirstChild("Torso"):WaitForChild("Breath").IsPlaying then
Humanoid.Parent:FindFirstChild("Torso"):WaitForChild("Breath"):Stop()
task.wait()
Humanoid.Parent:FindFirstChild("Torso"):WaitForChild("Breath"):Destroy()
end
if HB.IsPlaying then
HB:Stop()
end
end
end)```