How can I change all my if number is equal to etc into percentages so that players who have health upgrades etc it wont break, also I am pretty sure I don’t have to have all of those keycode lines but I don’t know how to go about that
Health check that I need to be converted is at the very bottom
local plr = game:GetService("Players").LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local GUI = game.StarterGui
local MENU = game.Players.LocalPlayer.PlayerGui
local TweenService = game:GetService('TweenService')
local AnimationEvent = game.ReplicatedStorage.AnimationEvent
local function tweenMax()
local Max = MENU["Full Health"].TextLabel
TweenService:Create(
Max,
TweenInfo.new(.5),
{TextTransparency = 0}
):Play()
wait(2)
TweenService:Create(
Max,
TweenInfo.new(.5),
{TextTransparency = 1}
):Play()
end
local function tweenScratch()
local Scratch = MENU.Scratch.TextLabel
TweenService:Create(
Scratch,
TweenInfo.new(.5),
{TextTransparency = 0}
):Play()
wait(2)
TweenService:Create(
Scratch,
TweenInfo.new(.5),
{TextTransparency = 1}
):Play()
end
local function tweenHalf()
local Half = MENU.Half.TextLabel
TweenService:Create(
Half,
TweenInfo.new(.5),
{TextTransparency = 0}
):Play()
wait(2)
TweenService:Create(
Half,
TweenInfo.new(.5),
{TextTransparency = 1}
):Play()
end
local function tweenQuarter()
local Quarter = MENU.Quarter.TextLabel
TweenService:Create(
Quarter,
TweenInfo.new(.5),
{TextTransparency = 0}
):Play()
wait(2)
TweenService:Create(
Quarter,
TweenInfo.new(.5),
{TextTransparency = 1}
):Play()
end
local function tweenDanger()
local Danger = MENU.Danger.TextLabel
TweenService:Create(
Danger,
TweenInfo.new(.5),
{TextTransparency = 0}
):Play()
wait(2)
TweenService:Create(
Danger,
TweenInfo.new(.5),
{TextTransparency = 1}
):Play()
end
local debounce = false
UIS.InputBegan:Connect(function(input, gpe)
if gpe or debounce then return end
if input.KeyCode == Enum.KeyCode.Q and Humanoid.Health == 100 then
debounce = true
print("I'm not hurt.")
AnimationEvent:FireServer()
tweenMax()
elseif input.KeyCode == Enum.KeyCode.Q and Humanoid.Health >= 80 then
debounce = true
print("Just a scratch.")
AnimationEvent:FireServer()
tweenScratch()
elseif input.KeyCode == Enum.KeyCode.Q and Humanoid.Health >= 60 then
debounce = true
print("I'll be alright.")
AnimationEvent:FireServer()
tweenHalf()
elseif input.KeyCode == Enum.KeyCode.Q and Humanoid.Health >= 30 then
debounce = true
print("I should be careful!")
AnimationEvent:FireServer()
tweenQuarter()
elseif input.KeyCode == Enum.KeyCode.Q and Humanoid.Health >= 0 then
debounce = true
print("I need to get to safety!")
AnimationEvent:FireServer()
tweenDanger()
end
task.wait(3)
debounce = false
end)