--		ndAnim:Play()

		--wait(2)
	--end

	hum.Sit = false
	if newBAV ~= nil then newBAV:remove() end
	if newBP ~= nil then newBP:remove() end
	if newBV ~= nil then newBV:remove() end

	if newBG ~= nil then newBG.cframe = CFrame.new(torsoPosition, target*Vector3.new(1,0,1) + Vector3.new(0, torsoPosition.Y, 0) ) end
	if newBG ~= nil then newBG.maxTorque = Vector3.new(newBG.P, newBG.P, newBG.P) end
	spinSound:Stop()
	wait(.25)
	if newBG ~= nil then newBG:remove() end
end


local lastKeyDown = 0
local dashTime = 0
local lastSlash = 0
local amAnimating = false
function onActivated()
	vChar = Tool.Parent
	if vChar == nil then return end
	hum = vChar:FindFirstChild("Humanoid")
	if hum == nil then return end
	--if not Tool.Enabled then return end
	if amAnimating then return end
	Tool.Enabled = false
	amAnimating = true

	torso = vChar:FindFirstChild("Torso")
	if torso == nil then Tool.Enabled = true return end

	t = r.Stepped:wait()
	if t - dashTime < .2 then
		-- dash attack
		dashIt(hum, torso)
		wait(.5)  -- reload time
		amAnimating = false
	elseif t - lastSlash < .2 then
		-- slash attack
		slashIt(hum, torso)
		--wait(1)
		amAnimating = false
		--wait(.5)  -- reload time
	else
		-- normal attack
		whackSound:Play()
		lastSlash = t
		amAnimating = false -- here must be before the wait, to allow for double-clix
		wait(.5)
	end
	if not amAnimating then Tool.Enabled = true end
end

local keyConnection = nil
function onKeyDown(key)
	if key:lower() == "w" then
		t = r.Stepped:wait()
		if (t - lastKeyDown < .2) then dashTime = t end
		lastKeyDown = t
	end
end

function onEquippedLocal(mouse)
	slashSound.Volume = 1 
	spinSound.Volume = 1
	whackSound.Volume = 1

	keyConnection = mouse.KeyDown:connect(onKeyDown)
end

function onUnequippedLocal()
	if keyConnection ~= nil then keyConnection:disconnect() end

	if newBV ~= nil then newBV:remove() end
	if newBG ~= nil then newBG:remove() end
	if newBAV ~= nil then newBAV:remove() end
	if newBP ~= nil then newBP:remove() end

	slashSound.Volume = 0
	spinSound.Volume = 0
	whackSound.Volume = 0
end

Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUnequippedLocal)
Tool.Activated:connect(onActivated)
 
