Permanent Auto Heal Galaxy

public
vxpreen Jun 29, 2024 Never 50
Clone
Lua paste1.txt 57 lines (45 loc) | 1.68 KB
1
-- loadstring(game:HttpGet("https://pastecode.dev/raw/y4w3sowg/paste1.txt"))()
2
3
local toolName = "Health potion"
4
local maxHealth = 100
5
local healthThreshold = 19.999
6
7
local player = game.Players.LocalPlayer
8
9
local function equipAndUseHealTool()
10
local character = player.Character or player.CharacterAdded:Wait()
11
local backpack = player.Backpack
12
13
local tool = backpack:FindFirstChild(toolName)
14
if tool then
15
character.Humanoid:EquipTool(tool)
16
wait()
17
tool:Activate()
18
19
-- Delay for a short period to allow the healing to finish
20
wait(0.0000001)
21
22
-- Check if the player is still holding the tool after healing
23
if character:FindFirstChild(toolName) then
24
local sword = backpack:FindFirstChild("Galaxy")
25
if sword then
26
character.Humanoid:EquipTool(sword)
27
end
28
end
29
end
30
end
31
32
local function checkHealthAndHeal()
33
local character = player.Character or player.CharacterAdded:Wait()
34
local humanoid = character:WaitForChild("Humanoid")
35
36
if humanoid.Health < healthThreshold then
37
equipAndUseHealTool()
38
end
39
end
40
41
-- Connect to Humanoid.HealthChanged to continuously monitor health
42
local function monitorHealth()
43
local character = player.Character or player.CharacterAdded:Wait()
44
local humanoid = character:WaitForChild("Humanoid")
45
46
humanoid.HealthChanged:Connect(function()
47
checkHealthAndHeal()
48
end)
49
end
50
51
-- Call monitorHealth function after character respawns
52
player.CharacterAdded:Connect(function()
53
monitorHealth()
54
end)
55
56
-- Initial call to monitorHealth to start monitoring health
57
monitorHealth()