local Tool = script.Parent
local number = 0
local player = game.Players.LocalPlayer
local BackpackFrame = player.PlayerGui:WaitForChild("BackpackGui").Frame
local ChangedText = BackpackFrame.ChangedText
Tool:WaitForChild("stacks").Changed:Connect(function(Value)
ChangedText.Text = "Changed: "..Value
end)
ChangedText.Text = "Changed: "..Tool.stacks.Value
-- 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()
Tool.stacks.Value -= 1
end
end
-- Handle equipped event
Tool.Equipped:Connect(function(mouse)
ChangedText.Visible = true
-- 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)
Tool.Unequipped:Connect(function()
ChangedText.Visible = false
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 >= number then
Heal(game.Players.LocalPlayer)
script.Parent.Handle.healed:Play()
elseif humanoid and humanoid.Health >= humanoid.MaxHealth then
Heal(game.Players.LocalPlayer)
script.Parent.Handle.healed:Play()
end
while wait() do
if Tool.stacks.Value == 0 then
Tool:Destroy()
ChangedText.Visible = false
wait(1)
break
end
end
end)