local Tool = script.Parent
-- Create the Heal function
local function Heal(player)
-- Check if the player is alive
if player.Character and player.Character:FindFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 then
-- Create a selection box on the player
local selectionBox = Instance.new("SelectionBox")
selectionBox.Adornee = player.Character
selectionBox.LineThickness = 0.1
selectionBox.Parent = player.Character
-- Wait for a short duration to show the selection box
wait(3)
-- Heal the player
player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
-- Remove the selection box
selectionBox:Destroy()
end
end
-- Handle equipped event
Tool.Equipped:Connect(function(mouse)
-- Create a selection box for the local player
local selectionBox = Instance.new("SelectionBox")
selectionBox.Adornee = game.Players.LocalPlayer.Character
selectionBox.LineThickness = 0.1
selectionBox.Parent = game.Players.LocalPlayer.Character
-- Wait for a short duration to show the selection box
wait(1)
-- Remove the selection box
selectionBox:Destroy()
end)
-- Handle mouse button click
Tool.Activated:Connect(function()
-- Check if the player is healing themselves
local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
if humanoid and humanoid.Health > 0 then
Heal(game.Players.LocalPlayer)
script.Parent.healed:Play()
elseif humanoid and humanoid.Health < humanoid.MaxHealth then
Tool:Destroy()
end
end)