--NOTE: Ugly!

local function OnKeyDown(key)
	key = string.lower(key)
	if key == 'e' then
		local now = time()
		if now > LastSummonTime + SUMMON_COOLDOWN then
			LastSummonTime = now
			local humanoid = MyModel:FindFirstChild('Humanoid')
			if humanoid then
				humanoid.WalkSpeed = 0
			end
			Spawn(function()
				for i = 1, 3 do
					if GongSound then GongSound:Play() end
					wait(1.5)
				end
			end)
			if SummonTrack then
				SummonTrack:Play()
				wait(3.125)
			end
			RaiseSkeletons()
			wait(1)
			if humanoid then
				humanoid.WalkSpeed = 18
			end
		end
	end
end

local function OnEquipped(mouse)
	MyModel = Tool.Parent
	mouse.KeyDown:connect(OnKeyDown)

	local humanoid = MyModel:FindFirstChild('Humanoid')
	if humanoid then -- Preload animations
		SummonTrack = humanoid:LoadAnimation(SummonAnimation)
	end
end

local function OnUnequipped()
	if SummonTrack then SummonTrack:Stop() end
end
