--[[
	Re-written by Phoenix
	(Actually works and doesn't lag the server to death K)
	Thanks
]]


local PartWeld = function(From, To)
	local WeldIns = Instance.new("WeldConstraint")
	WeldIns.Part0 = From
	WeldIns.Part1 = To
	WeldIns.Parent = From
	WeldIns.Name = "Weld"
	From.Anchored = false
end

local Weld = function(WeldTree, OverrideCenter)
	local Center = nil
	
	if OverrideCenter == nil then
		if WeldTree:FindFirstChildOfClass("MeshPart") then
			Center = WeldTree:FindFirstChildOfClass("MeshPart")
		elseif WeldTree:FindFirstChildOfClass("Part") then
			Center = WeldTree:FindFirstChildOfClass("Part")
		elseif WeldTree:FindFirstChildOfClass("UnionOperation") then
			Center = WeldTree:FindFirstChildOfClass("UnionOperation")
		end
	else
		Center = OverrideCenter
	end

	if Center ~= nil then
		for Index, ToWeld in pairs(WeldTree:GetDescendants()) do
			if ToWeld:IsA("BasePart") then
				PartWeld(ToWeld, Center)
			end
		end

		if WeldTree:IsA("BasePart") then
			PartWeld(WeldTree, Center)
		end
	end
end

local TweenService = game:GetService("TweenService")

local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local Died, Character = nil

local ToolEquipped = false
local Heal = 3
local Sounds = {
	CoilSound = Handle:WaitForChild("CoilSound"),
}

local Loop = function()
	while true do
		wait(1)
		
		if ToolEquipped == true then
			Character.Humanoid.Health = Character.Humanoid.Health + Heal
		end
	end	
end

local Equipped = function()
	ToolEquipped = true
	Character = Tool.Parent
	
	if Character == nil then
		return
	elseif Character.Humanoid == nil then
		return
	end
	
	Sounds.CoilSound:Play()
end

local Unequipped = function()
	ToolEquipped = false
end

Weld(Tool.Model, Tool.Handle)

Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(Unequipped)

Loop()
